From 6cfe0c7f79fa219605dea688cac65c974b7c8c88 Mon Sep 17 00:00:00 2001 From: David Houweling Date: Mon, 4 Nov 2024 09:02:59 +1100 Subject: [PATCH 1/5] try and fix deployment? --- .github/workflows/deploy.yml | 5 +++-- README.md | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 5717c00..09145d0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,9 +1,10 @@ -name: Deply +name: Deploy on: workflow_run: workflows: [Build] - types: [completed] + types: + - completed jobs: deploy: diff --git a/README.md b/README.md index 6b6c882..fae1e20 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,9 @@ This Discord bot can pull stats from Halo Waypoint and post accordingly. 1. [Download and install node.js](https://nodejs.org/en/download/package-manager) if you haven't done already 2. Clone the repo (assuming you already know how) 3. Follow the instructions from [`discord/cloudflare-sample-app`](https://github.com/discord/cloudflare-sample-app) - a. [Configuring project](https://github.com/discord/cloudflare-sample-app?tab=readme-ov-file#configuring-project) - b. [Creating your Cloudflare worker](https://github.com/discord/cloudflare-sample-app?tab=readme-ov-file#creating-your-cloudflare-worker) - c. [Running locally](https://github.com/discord/cloudflare-sample-app?tab=readme-ov-file#running-locally) + 1. [Configuring project](https://github.com/discord/cloudflare-sample-app?tab=readme-ov-file#configuring-project) + 2. [Creating your Cloudflare worker](https://github.com/discord/cloudflare-sample-app?tab=readme-ov-file#creating-your-cloudflare-worker) + 3. [Running locally](https://github.com/discord/cloudflare-sample-app?tab=readme-ov-file#running-locally) Now in a channel you can use `/stats` command. From a1210f7a0404a04f6ceb5fe2f5e82d2deb82dd55 Mon Sep 17 00:00:00 2001 From: David Houweling Date: Mon, 4 Nov 2024 11:05:14 +1100 Subject: [PATCH 2/5] make npm available --- .github/workflows/deploy.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 09145d0..bcf4285 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -12,6 +12,18 @@ jobs: if: ${{ github.event.workflow_run.conclusion == 'success' }} timeout-minutes: 60 steps: + - name: Check out Git repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "npm" + + - name: Install Node.js dependencies + run: npm ci + - name: Download artifacts uses: actions/download-artifact@v4 with: From ce860ac6ed348fde185c8dd6d34deecfb913e69c Mon Sep 17 00:00:00 2001 From: David Houweling Date: Mon, 4 Nov 2024 11:12:44 +1100 Subject: [PATCH 3/5] pass secrets through wrangler --- .github/workflows/deploy.yml | 12 ++++++++++++ b38b0d0 | 1 + 2 files changed, 13 insertions(+) create mode 160000 b38b0d0 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index bcf4285..5594bc0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -37,6 +37,18 @@ jobs: with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + secrets: | + DISCORD_APP_ID + DISCORD_PUBLIC_KEY + DISCORD_TOKEN + XBOX_USERNAME + XBOX_PASSWORD + env: + DISCORD_APP_ID: ${{ secrets.DISCORD_APP_ID }} + DISCORD_PUBLIC_KEY: ${{ secrets.DISCORD_PUBLIC_KEY }} + DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }} + XBOX_USERNAME: ${{ secrets.XBOX_USERNAME }} + XBOX_PASSWORD: ${{ secrets.XBOX_PASSWORD }} deploy-cancel: runs-on: ubuntu-latest if: ${{ github.event.workflow_run.conclusion == 'failure' }} diff --git a/b38b0d0 b/b38b0d0 new file mode 160000 index 0000000..b38b0d0 --- /dev/null +++ b/b38b0d0 @@ -0,0 +1 @@ +Subproject commit b38b0d04d8308aebf5a7fdf2fa9c9ae28e5ee29c From 7d9ca7d37cb0367e2e6b553603a8d6ee27b9f31a Mon Sep 17 00:00:00 2001 From: David Houweling Date: Mon, 4 Nov 2024 11:23:39 +1100 Subject: [PATCH 4/5] split vars from secrets --- .github/workflows/deploy.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 5594bc0..f5b394a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -37,17 +37,18 @@ jobs: with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - secrets: | + vars: | DISCORD_APP_ID DISCORD_PUBLIC_KEY - DISCORD_TOKEN XBOX_USERNAME + secrets: | + DISCORD_TOKEN XBOX_PASSWORD env: - DISCORD_APP_ID: ${{ secrets.DISCORD_APP_ID }} - DISCORD_PUBLIC_KEY: ${{ secrets.DISCORD_PUBLIC_KEY }} + DISCORD_APP_ID: ${{ vars.DISCORD_APP_ID }} + DISCORD_PUBLIC_KEY: ${{ vars.DISCORD_PUBLIC_KEY }} DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }} - XBOX_USERNAME: ${{ secrets.XBOX_USERNAME }} + XBOX_USERNAME: ${{ vars.XBOX_USERNAME }} XBOX_PASSWORD: ${{ secrets.XBOX_PASSWORD }} deploy-cancel: runs-on: ubuntu-latest From 27af0d3bbdcc9a93dc8db9f6f121298ac5e04948 Mon Sep 17 00:00:00 2001 From: David Houweling Date: Mon, 4 Nov 2024 11:40:25 +1100 Subject: [PATCH 5/5] environment be able to pick up if it is staging or production --- .github/workflows/deploy.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f5b394a..a9b711e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -9,6 +9,8 @@ on: jobs: deploy: runs-on: ubuntu-latest + environment: + name: ${{ github.event.pull_request.base.ref == 'main' && 'production' || 'staging' }} if: ${{ github.event.workflow_run.conclusion == 'success' }} timeout-minutes: 60 steps: