Skip to content

Commit

Permalink
initial workflow test
Browse files Browse the repository at this point in the history
  • Loading branch information
mandar1jn committed Apr 5, 2024
1 parent a4e02c7 commit 1fdc287
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Deploy staging

on:
workflow_dispatch:
push:
branches:
- main

jobs:
deploy:
name: Deploy staging
runs-on: ubuntu-latest
environment: staging
env:
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
DISCORD_APPLICATION_ID: ${{ secrets.DISCORD_APPLICATION_ID }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup bun
uses: oven-sh/setup-bun@v1

- name: Install dependencies
run: bun install

- name: Deploy staging
uses: cloudflare/[email protected]
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
preCommands: bun register
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"type": "module",
"scripts": {
"start": "wrangler dev",
"dev": "wrangler dev"
"dev": "wrangler dev",
"register": "bun ./src/register.ts"
},
"engines": {
"node": ">=18.18.0"
Expand Down
4 changes: 2 additions & 2 deletions src/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {resolve} from 'node:path';

config({ path: resolve(process.cwd(), '.dev.vars') });

if (!process.env.DISCORD_TOKEN || !process.env.DISCORD_CLIENT_ID) {
if (!process.env.DISCORD_TOKEN || !process.env.DISCORD_APPLICATION_ID) {
console.error('The required tokens to register commands were not present');
process.exit(1);
}
Expand All @@ -24,6 +24,6 @@ for (const commandName in CommandList) {

console.log(`Started refreshing ${commands.length} commands.`);

const data: any = await rest.put(Routes.applicationCommands(process.env.DISCORD_CLIENT_ID), { body: commands });
const data: any = await rest.put(Routes.applicationCommands(process.env.DISCORD_APPLICATION_ID), { body: commands });

console.log(`Successfully reloaded ${data.length} commands.`);

0 comments on commit 1fdc287

Please sign in to comment.