Deploy Worker #537
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Worker | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| jobs: | |
| deploy: | |
| name: Deploy Cloudflare Worker | |
| timeout-minutes: 5 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1 | |
| with: | |
| egress-policy: block | |
| allowed-endpoints: > | |
| sparrow.cloudflare.com:443 | |
| api.cloudflare.com:443 | |
| api.github.com:443 | |
| github.com:443 | |
| hooks.slack.com:443 | |
| registry.npmjs.org:443 | |
| sentry.io:443 | |
| us.sentry.io:443 | |
| - name: Git Checkout | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Setup Node | |
| uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 | |
| with: | |
| node-version: lts/* | |
| cache: 'npm' | |
| - name: Install Dependencies | |
| run: npm ci | |
| - name: Deploy to Staging | |
| if: github.event_name == 'push' | |
| uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65 # v3.14.1 | |
| with: | |
| apiToken: ${{ secrets.CF_API_TOKEN }} | |
| command: deploy --env staging --outdir=./dist | |
| - name: Upload sourcemaps for dist-worker-staging | |
| if: github.event_name == 'push' | |
| env: | |
| SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
| run: | | |
| npx sentry-cli sourcemaps inject --org nodejs --project dist-worker-staging ./dist && npx sentry-cli sourcemaps upload --org nodejs --project dist-worker-staging ./dist | |
| - name: Deploy to Production | |
| if: github.event_name == 'workflow_dispatch' | |
| uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65 # v3.14.1 | |
| with: | |
| apiToken: ${{ secrets.CF_API_TOKEN }} | |
| command: deploy --env prod --outdir=./dist | |
| - name: Alert on Failure | |
| if: failure() && github.repository == 'nodejs/release-cloudflare-worker' | |
| uses: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661 # 2.3.3 | |
| env: | |
| SLACK_COLOR: '#DE512A' | |
| SLACK_ICON: https://github.com/nodejs.png?size=48 | |
| SLACK_TITLE: Deployment failed (${{ github.ref }}) | |
| SLACK_MESSAGE: A deployment of the Release Worker has failed. | |
| SLACK_USERNAME: nodejs-bot | |
| SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} |