-
Notifications
You must be signed in to change notification settings - Fork 5
61 lines (59 loc) · 2.15 KB
/
deploy-analytics.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# 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 }}