-
-
Notifications
You must be signed in to change notification settings - Fork 3
270 lines (248 loc) · 11 KB
/
deployment.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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
name: Website Deployment
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
actions: read
checks: read
contents: read
deployments: write
issues: write
discussions: read
packages: read
pages: read
pull-requests: write
repository-projects: read
security-events: read
statuses: read
outputs:
skip: ${{ steps.moon-build.outputs.skip }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
- uses: moonrepo/setup-toolchain@abc36a5d744a0b6dff6fd87201c49917c145deb9 # v0.3.1
with:
auto-install: true
- id: moon-build
run: |
temp_file=$(mktemp)
moon --color --log info ci site:build | tee "$temp_file"
if grep -q "No targets to run based on touched files" "$temp_file"; then
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "skip=false" >> $GITHUB_OUTPUT
fi
rm "$temp_file"
env:
ASTRO_STUDIO_APP_TOKEN: ${{ secrets.ASTRO_STUDIO_APP_TOKEN }}
MOONBASE_SECRET_KEY: ${{ secrets.MOONBASE_SECRET_KEY }}
- uses: moonrepo/run-report-action@0e591adc3fbc65a5c9b2f4738368f378c2efaa79 # v1.8.0
if: ${{ steps.moon-build.outputs.skip != 'true' }}
with:
access-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
if: ${{ steps.moon-build.outputs.skip != 'true' }}
id: artifact-upload
with:
# Name of the artifact to upload.
# Optional. Default is 'artifact'
name: ${{ github.workflow_sha }}
# A file, directory or wildcard pattern that describes what to upload
# Required.
path: apps/site/dist/
# The desired behavior if no files are found using the provided path.
# Available Options:
# warn: Output a warning but do not fail the action
# error: Fail the action with an error message
# ignore: Do not output any warnings or errors, the action does not fail
# Optional. Default is 'warn'
if-no-files-found: warn
# Duration after which artifact will expire in days. 0 means using default retention.
# Minimum 1 day.
# Maximum 90 days unless changed from the repository settings page.
# Optional. Defaults to repository settings.
retention-days: 1
# The level of compression for Zlib to be applied to the artifact archive.
# The value can range from 0 to 9.
# For large files that are not easily compressed, a value of 0 is recommended for significantly faster uploads.
# Optional. Default is '6'
compression-level: 0
# If true, an artifact with a matching name will be deleted before a new one is uploaded.
# If false, the action will fail if an artifact for the given name already exists.
# Does not fail if the artifact does not exist.
# Optional. Default is 'false'
overwrite: true
deploy-preview:
needs: build
if: ${{ github.ref != 'refs/heads/main' && needs.build.outputs.skip != 'true' }}
name: Deploy - Preview
runs-on: ubuntu-latest
permissions:
actions: read
checks: read
contents: read
deployments: write
issues: write
discussions: read
packages: read
pages: read
pull-requests: write
repository-projects: read
security-events: read
statuses: read
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
ref: ${{ github.event.pull_request.head.ref }}
- uses: moonrepo/setup-toolchain@abc36a5d744a0b6dff6fd87201c49917c145deb9 # v0.3.1
with:
auto-install: true
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
id: deployment
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { default: script } = await import('${{ github.workspace }}/.github/scripts/create-deployment.js')
await script({github, context, core})
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
# Name of the artifact to download.
# If unspecified, all artifacts for the run are downloaded.
# Optional.
name: ${{ github.workflow_sha}}
# Destination path. Supports basic tilde expansion.
# Optional. Default is $GITHUB_WORKSPACE
path: apps/site/dist/
# A glob pattern to the artifacts that should be downloaded.
# Ignored if name is specified.
# Optional.
# pattern:
# When multiple artifacts are matched, this changes the behavior of the destination directories.
# If true, the downloaded artifacts will be in the same directory specified by path.
# If false, the downloaded artifacts will be extracted into individual named directories within the specified path.
# Optional. Default is 'false'
merge-multiple: true
# The GitHub token used to authenticate with the GitHub API.
# This is required when downloading artifacts from a different repository or from a different workflow run.
# Optional. If unspecified, the action will download artifacts from the current repo and the current workflow run.
# github-token:
# The repository owner and the repository name joined together by "/".
# If github-token is specified, this is the repository that artifacts will be downloaded from.
# Optional. Default is ${{ github.repository }}
# repository:
# The id of the workflow run where the desired download artifact was uploaded from.
# If github-token is specified, this is the run that artifacts will be downloaded from.
# Optional. Default is ${{ github.run_id }}
# run-id:
- uses: cloudflare/wrangler-action@a08dc762e87e8754e0d56a16a35a70b406bc869f # v3.6.1
id: wrangler
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
# renovate: datasource=npm depName=wrangler
wranglerVersion: "3.62.0"
workingDirectory: "apps/site"
packageManager: pnpm
command: pages deploy dist --project-name astrolicious
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
DEPLOYMENT_ID: ${{ steps.deployment.outputs.deployment-id }}
DEPLOYMENT_URL: ${{ steps.wrangler.outputs.deployment-url }}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { default: script } = await import('${{ github.workspace }}/.github/scripts/update-deployment.js')
await script({github, context, core})
deploy-production:
if: ${{ github.ref == 'refs/heads/main' && needs.build.outputs.skip != 'true' }}
needs: build
name: Deploy - Production
runs-on: ubuntu-latest
permissions:
actions: read
checks: read
contents: read
deployments: write
issues: write
discussions: read
packages: read
pages: read
pull-requests: write
repository-projects: read
security-events: read
statuses: read
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
ref: ${{ github.event.pull_request.head.ref }}
- uses: moonrepo/setup-toolchain@abc36a5d744a0b6dff6fd87201c49917c145deb9 # v0.3.1
with:
auto-install: true
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
id: deployment
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { default: script } = await import('${{ github.workspace }}/.github/scripts/create-deployment.js')
await script({github, context, core})
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
# Name of the artifact to download.
# If unspecified, all artifacts for the run are downloaded.
# Optional.
name: ${{ github.workflow_sha}}
# Destination path. Supports basic tilde expansion.
# Optional. Default is $GITHUB_WORKSPACE
path: apps/site/dist/
# A glob pattern to the artifacts that should be downloaded.
# Ignored if name is specified.
# Optional.
# pattern:
# When multiple artifacts are matched, this changes the behavior of the destination directories.
# If true, the downloaded artifacts will be in the same directory specified by path.
# If false, the downloaded artifacts will be extracted into individual named directories within the specified path.
# Optional. Default is 'false'
merge-multiple: true
# The GitHub token used to authenticate with the GitHub API.
# This is required when downloading artifacts from a different repository or from a different workflow run.
# Optional. If unspecified, the action will download artifacts from the current repo and the current workflow run.
# github-token:
# The repository owner and the repository name joined together by "/".
# If github-token is specified, this is the repository that artifacts will be downloaded from.
# Optional. Default is ${{ github.repository }}
# repository:
# The id of the workflow run where the desired download artifact was uploaded from.
# If github-token is specified, this is the run that artifacts will be downloaded from.
# Optional. Default is ${{ github.run_id }}
# run-id:
- uses: cloudflare/wrangler-action@a08dc762e87e8754e0d56a16a35a70b406bc869f # v3.6.1
id: wrangler
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
# renovate: datasource=npm depName=wrangler
wranglerVersion: "3.62.0"
workingDirectory: "apps/site"
packageManager: pnpm
command: pages deploy dist --project-name astrolicious
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
DEPLOYMENT_ID: ${{ steps.deployment.outputs.deployment-id }}
DEPLOYMENT_URL: ${{ steps.wrangler.outputs.deployment-url }}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { default: script } = await import('${{ github.workspace }}/.github/scripts/update-deployment.js')
await script({github, context, core})