From 7f042394754145b16052283bbe3f0948cfc9bd7f Mon Sep 17 00:00:00 2001 From: minikin Date: Wed, 13 Nov 2024 14:21:18 +0100 Subject: [PATCH] Create deploy.yml --- .github/workflows/deploy.yml | 72 ++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..17a80c0 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,72 @@ +name: Deploy Catalyst Voices Updates + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + pages: write + id-token: write + + steps: + - uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: "18" + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build + + - name: Setup Pages + uses: actions/configure-pages@v4 + + - name: Upload Preview Artifact + if: github.event_name == 'pull_request' + uses: actions/upload-artifact@v4 + with: + name: github-pages + path: dist + retention-days: 1 + + - name: Deploy Preview + if: github.event_name == 'pull_request' + uses: actions/deploy-pages@v3 + with: + preview: true + artifact_name: github-pages + + - name: Add Preview URL Comment + if: github.event_name == 'pull_request' + uses: actions/github-script@v6 + with: + script: | + const preview_url = `https://${context.repo.owner}.github.io/${context.repo.repo}/pr-preview/pr-${context.issue.number}`; + github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: `🚀 Preview deployment is ready!\nURL: ${preview_url}` + }) + + - name: Upload Production Artifact + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + uses: actions/upload-pages-artifact@v3 + with: + path: dist + + - name: Deploy Production + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + uses: actions/deploy-pages@v3