Skip to content

V3/dev (#1274)

V3/dev (#1274) #261

# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Deploy Analytics
on:
workflow_dispatch:
inputs:
environment:
description: 'Choose an environment to deploy to: <dev|prod>'
required: true
default: 'dev'
push:
branches:
- v3/dev
- v3/prod
jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ github.ref == 'refs/heads/v3/prod' && 'prod' || 'dev' }}
permissions:
contents: read
deployments: write
name: Deploy to Cloudflare Pages
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
cache: 'yarn'
- name: Yarn Install
run: yarn install --frozen-lockfile
- name: Check if analytics project is affected
id: check-affected
run: |
echo "is_affected=$(yarn --silent nx print-affected --base=HEAD~1 --head=HEAD | jq '.projects | contains(["analytics"])')" >> $GITHUB_OUTPUT
- name: Build Web
if: ${{ steps.check-affected.outputs.is_affected == 'true' }}
working-directory: apps/analytics
run: yarn run next-on-pages
env:
NX_SEGMENT_KEY: ${{ secrets.NX_SEGMENT_KEY }}
NX_SUBGRAPH_API_KEY: ${{ secrets.NX_SUBGRAPH_UI_KEY }}
NX_ENV: ${{ github.ref == 'refs/heads/v3/prod' && 'prod' || 'dev' }}
NX_COMMIT_REF: ${{ github.sha }}
- name: Publish Dev
if: ${{ steps.check-affected.outputs.is_affected == 'true' }}
uses: cloudflare/pages-action@1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: analytics-${{ github.ref == 'refs/heads/v3/prod' && 'prod' || 'dev' }}
directory: apps/analytics/.vercel/output/static
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Slack Notification
if: ${{ steps.check-affected.outputs.is_affected == 'true' }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}