feat: Migrate Actions #2
This file contains 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: Prod Build and Deploy (CloudFlare) | |
on: | |
push: | |
branches: ['main'] | |
workflow_dispatch: | |
pull_request: | |
env: | |
GOOGLE_ANALYTICS_TRACKING_ID: ${{ secrets.GOOGLE_TAGMANAGER_ID_SCDF }} | |
permissions: | |
contents: read | |
pull-requests: write | |
jobs: | |
# build and deploy staging | |
build: | |
name: Build site | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
# agent may give node which doesn't work for us | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18.2.0 | |
# setup cf cli with bg plugin and login | |
# - uses: jvalkeal/setup-cf-cli@v0 | |
# with: | |
# version: 6.51.0 | |
# plugin-repo: https://plugins.cloudfoundry.org | |
# plugin-id: blue-green-deploy | |
# login: true | |
# do site build and prepare for cf push | |
- name: Yarn build | |
env: | |
NODE_OPTIONS: '--openssl-legacy-provider' | |
run: | | |
yarn install | |
yarn run fix | |
yarn build | |
yarn run prepare-cf-push | |
# Publish | |
- name: Publish to Cloudflare Pages | |
id: cloudflare-publish | |
uses: cloudflare/pages-action@v1 | |
with: | |
apiToken: ${{ secrets.CF_API_TOKEN }} | |
accountId: ${{ secrets.CF_ACCOUNT_ID }} | |
projectName: ${{ secrets.CF_PROJECT_NAME }} | |
directory: public | |
# Comment PR with the preview URL | |
- uses: mshick/add-pr-comment@v2 | |
with: | |
message-id: cloudflare-deploy | |
message: | | |
🚀 Preview at ${{ steps.cloudflare-publish.outputs.url }} | |
# Chat Notification | |
# - name: Google Chat Notification | |
# uses: Co-qn/google-chat-notification@3691ccf4763537d6e544bc6cdcccc1965799d056 | |
# with: | |
# name: Build (${{ matrix.runner }}) | |
# url: ${{ secrets.GOOGLE_CHAT_WEBHOOK }} | |
# status: ${{ job.status }} | |
# if: always() |