Repository navigation
120 lines (102 loc) · 3.28 KB
/
Copy pathci-cd.yml
File metadata and controls
120 lines (102 loc) · 3.28 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: CI/CD
on:
push:
pull_request:
branches: main
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
validation:
name: Validation
runs-on: ubuntu-slim
timeout-minutes: 15
steps:
- name: Checkout Repository
uses: actions/checkout@v7.0.1
- name: Setup Node.js
uses: actions/setup-node@v7.1.0
with:
node-version: '26'
cache: 'npm'
- name: Install Dependencies
id: dependencies
run: npm ci
- name: Check Formatting
if: ${{ !cancelled() && steps.dependencies.outcome == 'success' }}
run: npm run format:check
- name: Astro Checks
if: ${{ !cancelled() && steps.dependencies.outcome == 'success' }}
run: npm run check
- name: Run Tests
if: ${{ !cancelled() && steps.dependencies.outcome == 'success' }}
run: npm test
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout Repository
uses: actions/checkout@v7.0.1
- name: Setup Node.js
uses: actions/setup-node@v7.1.0
with:
node-version: '26'
cache: 'npm'
- name: Install Dependencies
run: npm ci
- name: Build
run: npm run build
- name: Validate Worker Deployment
run: npm run cf-deploy -- --prebuilt --dry-run --mode production
- name: Upload Worker Build
if: github.event_name == 'push'
uses: actions/upload-artifact@v7.0.2
with:
name: worker-build
overwrite: true
path: .cloudflare/output/
include-hidden-files: true
if-no-files-found: error
retention-days: 1
preview:
name: Cloudflare Preview
needs: [validation, build]
if: ${{ !cancelled() && github.event_name == 'push' && github.ref_type == 'branch' && github.ref != 'refs/heads/main' }}
permissions:
contents: read
actions: read
pull-requests: write
uses: FOSSBilling/.workflows/.github/workflows/cloudflare-workers.yml@a477d29315c97bf3218f68ea61ea67967c5a0c51 # main
with:
operation: deploy
mode: preview
cli: cf
build-result: ${{ needs.build.result }}
checks-result: ${{ needs.validation.result }}
pr-comment: true
pr-base-branch: main
environment: preview
artifact-name: worker-build
artifact-path: .cloudflare/output/
secrets:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
deploy:
name: Deploy Production
needs: [validation, build]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: FOSSBilling/.workflows/.github/workflows/cloudflare-workers.yml@a477d29315c97bf3218f68ea61ea67967c5a0c51 # main
with:
operation: deploy
mode: production
cli: cf
prebuilt: true
environment: production
artifact-name: worker-build
artifact-path: .cloudflare/output/
secrets:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}