-
-
Notifications
You must be signed in to change notification settings - Fork 34
100 lines (80 loc) · 2.45 KB
/
test-and-release.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Test and Release
# Run this job on all pushes to main and for pull requests
on:
push:
branches:
# This avoids having duplicate builds in non-forked PRs
- "main"
pull_request: {}
# Cancel previous PR/branch runs when a new commit is pushed
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
# ===================
# Tests everything
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x] # This should be LTS
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- name: Install dependencies
run: yarn install --immutable
- name: Check TypeScript code
run: yarn check
- name: Run linter
run: yarn run lint
- name: Try to generate index file
run: yarn build:index
- name: Run component tests
run: yarn run test:ci
- name: Check file download/integrity of changed files
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const script = require(`${process.env.GITHUB_WORKSPACE}/.github/scripts/check-integrity.cjs`);
return script({github, context, core});
# ===================
# Deploys successful builds on the main branch to Cloudflare
deploy:
if: |
github.event_name == 'push' &&
github.ref == 'refs/heads/main'
needs: [test]
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x] # This should be LTS
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- name: Install dependencies
run: yarn install --immutable
- name: Generate index file
run: yarn build:index
- name: Publish to Cloudflare
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
packageManager: yarn
- name: Upload config files to Cloudflare
env:
BASE_URL: ${{ secrets.BASE_URL }}
ADMIN_SECRET: ${{ secrets.ADMIN_SECRET }}
run: yarn upload