Skip to content

Commit 67dfa34

Browse files
committed
Safer deploy
1 parent 19517ae commit 67dfa34

4 files changed

Lines changed: 87 additions & 46 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,28 @@ jobs:
1313
steps:
1414
- name: Checkout the repository
1515
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
16-
- name: Install pnpm
17-
uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
18-
- name: Install Node.js
19-
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
20-
with:
21-
node-version-file: .node-version
22-
cache: pnpm
16+
- name: Install Node.js & pnpm
17+
uses: pnpm/setup@84cb39b217b10273981911c288cd62326dc7c6d2 # v2.0.2
2318
- name: Install dependencies
24-
run: pnpm install --ignore-scripts
19+
run: pnpm ci
2520
- name: Run tests
2621
run: pnpm test
2722

28-
deploy:
29-
name: Deploy
23+
build:
24+
name: Build
3025
runs-on: ubuntu-latest
3126
permissions:
3227
contents: read
33-
packages: write
34-
id-token: write
3528
if: github.ref == 'refs/heads/main'
36-
concurrency:
37-
group: deploy
38-
cancel-in-progress: false
3929
needs:
4030
- test
4131
steps:
4232
- name: Checkout the repository
4333
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
44-
- name: Install pnpm
45-
uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
46-
- name: Install Node.js
47-
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
48-
with:
49-
node-version-file: .node-version
34+
- name: Install Node.js & pnpm
35+
uses: pnpm/setup@84cb39b217b10273981911c288cd62326dc7c6d2 # v2.0.2
36+
- name: Install dependencies
37+
run: pnpm ci
5038
- name: Install production dependencies
5139
run: pnpm install --prod --ignore-scripts
5240
- name: Build regions
@@ -55,6 +43,37 @@ jobs:
5543
run: pnpm build
5644
- name: Bundle server with production dependencies
5745
run: pnpm --filter=server --prod deploy --legacy server/dist
46+
- name: Pack build artifacts
47+
run: tar -cf dist.tar client/dist server/dist
48+
- name: Upload build artifacts
49+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
50+
with:
51+
name: dist
52+
path: dist.tar
53+
retention-days: 1
54+
55+
deploy:
56+
name: Deploy
57+
runs-on: ubuntu-latest
58+
permissions:
59+
contents: read
60+
packages: write
61+
id-token: write
62+
if: github.ref == 'refs/heads/main'
63+
concurrency:
64+
group: deploy
65+
cancel-in-progress: false
66+
needs:
67+
- build
68+
steps:
69+
- name: Checkout the repository
70+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
71+
- name: Download build artifacts
72+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
73+
with:
74+
name: dist
75+
- name: Unpack build artifacts
76+
run: tar -xf dist.tar && rm dist.tar
5877
- name: Build Docker image
5978
run: docker build -t ghcr.io/browserslist/browsersl.ist:latest .
6079
- name: Login to GitHub Container Registry
@@ -86,7 +105,7 @@ jobs:
86105
| jq -r '.[] | select(.metadata.container.tags == []) | .id')
87106
if [ -n "$IDS" ]; then
88107
for ID in $IDS; do
89-
echo "Deleting browsersl.ist version $ID"
108+
echo "Deleting version $ID"
90109
gh api -X DELETE "$VERSIONS/$ID" --silent
91110
done
92111
else

‎.github/workflows/update.yml‎

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,61 @@ on:
55
permissions:
66
contents: none
77
jobs:
8-
update:
8+
check:
99
name: Check
1010
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
outputs:
14+
changes: ${{ steps.changes.outputs.changes }}
1115
steps:
1216
- name: Checkout the repository
1317
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
1418
with:
15-
token: ${{ secrets.DEPLOY_TOKEN }}
16-
- name: Install pnpm
17-
uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
18-
- name: Install Node.js
19-
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
20-
with:
21-
node-version-file: .node-version
22-
cache: pnpm
19+
persist-credentials: false
20+
- name: Install Node.js & pnpm
21+
uses: pnpm/setup@84cb39b217b10273981911c288cd62326dc7c6d2 # v2.0.2
2322
- name: Install dependencies
24-
run: pnpm install --ignore-scripts
23+
run: pnpm ci
2524
- name: Update dependencies
26-
run: pnpm update -r caniuse-lite browserslist browserslist-lint baseline-browser-mapping
25+
run: pnpm update -r --ignore-scripts caniuse-lite browserslist browserslist-lint baseline-browser-mapping
2726
- name: Check dependencies
2827
id: changes
2928
run: node ./scripts/check-changes.js
30-
- name: Setup git config
31-
if: steps.changes.outputs.changes
32-
run: |
33-
git config user.name "Andrey Sitnik"
34-
git config user.email "andrey@sitnik.es"
3529
- name: Run tests
3630
if: steps.changes.outputs.changes
3731
run: pnpm test
38-
- name: Commit changes
32+
- name: Upload manifests
3933
if: steps.changes.outputs.changes
34+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
35+
with:
36+
name: manifests
37+
retention-days: 1
38+
path: |
39+
pnpm-lock.yaml
40+
package.json
41+
*/package.json
42+
43+
push:
44+
name: Push
45+
runs-on: ubuntu-latest
46+
needs: check
47+
if: needs.check.outputs.changes
48+
steps:
49+
- name: Checkout the repository
50+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
51+
with:
52+
token: ${{ secrets.DEPLOY_TOKEN }}
53+
- name: Download manifests
54+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
55+
with:
56+
name: manifests
57+
- name: Setup git config
58+
run: |
59+
git config user.name "Andrey Sitnik"
60+
git config user.email "andrey@sitnik.es"
61+
- name: Commit and push changes
4062
run: |
4163
git add pnpm-lock.yaml ':(glob)**/package.json'
4264
git commit -m "Update caniuse-lite and browserslist"
43-
- name: Push changes
44-
if: steps.changes.outputs.changes
45-
run: git push --follow-tags
65+
git push --follow-tags

‎.node-version‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎package.json‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@
2727
"svgo": "^4.1.0",
2828
"typescript": "^7.0.2"
2929
},
30-
"engines": {
31-
"node": ">=26"
30+
"devEngines": {
31+
"runtime": {
32+
"name": "node",
33+
"version": "26.8.1"
34+
}
3235
},
33-
"packageManager": "pnpm@11.20.0"
36+
"packageManager": "pnpm@12.0.0"
3437
}

0 commit comments

Comments
 (0)