From 5fa87dba888966c42f73709b1901a65603e8adfd Mon Sep 17 00:00:00 2001 From: David Houweling Date: Sun, 3 Nov 2024 21:34:40 +1100 Subject: [PATCH] setup deployment --- .github/workflows/build.yml | 6 +++++- .github/workflows/deploy.yml | 32 ++++++++++++++++++++++++++++++++ package.json | 3 ++- 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1adb67c..be1ec19 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,6 @@ jobs: node-version: 20 cache: "npm" - # ESLint and Prettier must be in `package.json` - name: Install Node.js dependencies run: npm ci @@ -32,3 +31,8 @@ jobs: - name: Run build run: npm run build + + - uses: actions/upload-artifact@v4 + with: + name: guilt-spark-build + path: ./dist diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..5717c00 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,32 @@ +name: Deply + +on: + workflow_run: + workflows: [Build] + types: [completed] + +jobs: + deploy: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + timeout-minutes: 60 + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: guilt-spark-build + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ secrets.GITHUB_TOKEN }} + + - uses: actions/checkout@v4 + - name: Build & Deploy Worker + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + deploy-cancel: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'failure' }} + steps: + - run: echo 'The triggering workflow failed' + - run: exit 1 diff --git a/package.json b/package.json index 709b271..4781879 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,8 @@ "lint": "npx eslint .", "lint:fix": "npx eslint . --fix", "build:generate-types": "wrangler types --experimental-include-runtime", - "build": "tsc --project tsconfig.build.json" + "build": "tsc --project tsconfig.build.json", + "publish": "wrangler deploy" }, "dependencies": { "@xboxreplay/xboxlive-auth": "^4.0.0",