Deploy Worker #609
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@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.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 | |
| release-assets.githubusercontent.com:443 | |
| - name: Git Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Setup Node | |
| uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 | |
| with: | |
| node-version: lts/* | |
| cache: 'npm' | |
| - name: Install Dependencies | |
| run: npm ci | |
| - name: Deploy to Staging | |
| if: github.event_name == 'push' | |
| env: | |
| SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }} | |
| run: node --run deploy:staging | |
| - name: Deploy to Production | |
| if: github.event_name == 'workflow_dispatch' | |
| env: | |
| SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }} | |
| run: node --run deploy:prod | |
| - name: Upload Source Maps to Sentry | |
| env: | |
| SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
| SENTRY_ORG: nodejs-org | |
| SENTRY_PROJECT: ${{ (github.event_name == 'workflow_dispatch' && 'dist-worker-prod') || 'dist-worker-staging' }} | |
| run: ./scripts/upload-sourcemaps.sh | |
| - 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 }} |