-
-
Notifications
You must be signed in to change notification settings - Fork 3
173 lines (166 loc) · 4.58 KB
/
ci.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: Continuous Integration
on:
push:
branches: main
pull_request:
branches: main
defaults:
run:
shell: bash
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
- run: deno task lint
quick-test:
name: Quick test
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
- run: deno task install:deno
- run: deno task test:deno
test:
name: Test
runs-on: ${{ matrix.os }}
needs:
- lint
- quick-test
permissions:
contents: read
strategy:
fail-fast: false
matrix:
runtime:
- name: deno
version: 2.x
- name: node
version: 22.x
- name: bun
# https://github.com/oven-sh/setup-bun/issues/37
# version: 1.x
version: latest
os:
- ubuntu-latest
# - windows-latest
- macos-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
- if: matrix.runtime.name == 'deno'
uses: denoland/setup-deno@v2
with:
deno-version: ${{ matrix.runtime.version }}
- if: matrix.runtime.name == 'node'
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.runtime.version }}
- if: matrix.runtime.name == 'bun'
uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ matrix.runtime.version }}
- run: deno task install:${{ matrix.runtime.name }}
- run: deno task test:${{ matrix.runtime.name }}
preview:
name: Preview
runs-on: ubuntu-latest
needs:
- lint
- quick-test
permissions:
id-token: write
contents: read
environment:
name: preview
url: ${{ steps.preview.outputs.url }}
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
- run: deno task ci:setup-deno-deploy
id: setup_github_actions
- run: deno task install:deno
- uses: denoland/deployctl@v1
id: preview
# https://github.com/denoland/deployctl/issues/350
with:
project: ${{ steps.setup_github_actions.outputs.project }}
entrypoint: ${{ steps.setup_github_actions.outputs.entrypoint }}
import-map: ${{ steps.setup_github_actions.outputs.import_map }}
include: ${{ steps.setup_github_actions.outputs.include }}
exclude: ${{ steps.setup_github_actions.outputs.exclude }}
autogenerate:
name: Autogenerate
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
# needs:
# - test
permissions:
contents: write
steps:
- uses: actions/create-github-app-token@v1
id: autogenerated
with:
app-id: 1090539
private-key: ${{ secrets.AUTOGENERATED_CONTENT_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
token: ${{ steps.autogenerated.outputs.token }}
- uses: denoland/setup-deno@v2
- uses: actions/setup-node@v4
with:
node-version: 22.x
- run: deno task ci:autogenerate
- name: Run git push
run: |
if [ -n "$(git status --porcelain)" ]; then
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git diff
git add .
git commit -m 'ci: autogenerated changes'
git pull --rebase
git push
fi
publish:
name: Publish
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
needs:
- autogenerate
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
- run: deno publish
deploy:
name: Deploy
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
needs:
- preview
- publish
permissions:
id-token: write
pages: write
environment:
name: deployment
url: ${{ steps.deployment.outputs.url }}
steps:
- uses: actions/checkout@v4
with:
ref: main
- uses: actions/configure-pages@v5
- uses: denoland/setup-deno@v2
- run: deno task ci:setup-github-pages
- uses: actions/upload-pages-artifact@v3
- uses: actions/deploy-pages@v4
id: deployment