-
Notifications
You must be signed in to change notification settings - Fork 2.1k
77 lines (65 loc) · 2.13 KB
/
ci.yaml
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: CI/CD
on:
push:
branches:
- master
pull_request:
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup and Build
uses: ./.github/actions/setup-and-build
- name: Run type check
run: pnpm run typecheck
- name: Run ESLint
run: pnpm run lint
- name: Run tests
run: pnpm run test
build-and-deploy:
name: Build and Deploy
needs: test
runs-on: ubuntu-latest
environment: ${{ github.ref_name == 'master' && 'production' || 'staging' }}
if: ${{ github.ref != 'refs/heads/master' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup and Build
uses: ./.github/actions/setup-and-build
- name: Deploy to Cloudflare
id: deploy
uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: '* -w'
packageManager: pnpm
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy
- name: Deployment URL
env:
DEPLOYMENT_URL: ${{ steps.deploy.outputs.deployment-url }}
run: echo $DEPLOYMENT_URL
- name: Comment on Commit
if: github.event_name == 'push'
uses: hasura/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
id: deploy-preview-commit
commit-sha: ${{ github.sha }}
message: '${{ github.sha }} has been deployed to ${{ steps.deploy.outputs.deployment-url }} :rocket:'
recreate: true
- name: Comment on PR
if: github.event_name == 'pull_request'
uses: hasura/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
id: deploy-preview-pr
number: ${{ github.event.number }}
message: '#${{ github.event.number }} has been deployed to ${{ steps.deploy.outputs.deployment-url }} :rocket:'
recreate: true