Skip to content

Commit e9a092a

Browse files
authored
Harden GitHub Actions workflows (#884)
* Harden GitHub Actions workflows
1 parent a432fd2 commit e9a092a

3 files changed

Lines changed: 73 additions & 21 deletions

File tree

‎.github/dependabot.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ updates:
55
schedule:
66
interval: monthly
77
versioning-strategy: increase
8+
cooldown:
9+
default-days: 7
810
- package-ecosystem: github-actions
911
directory: "/"
1012
schedule:
1113
interval: monthly
14+
cooldown:
15+
default-days: 7

‎.github/workflows/codespell.yml‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,24 @@ on:
55
push:
66
branches: [ master ]
77

8+
permissions: {}
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
814
jobs:
915
codespell:
16+
name: Codespell
1017
runs-on: ubuntu-latest
18+
timeout-minutes: 5
19+
permissions:
20+
contents: read
1121
steps:
12-
- uses: actions/checkout@v2
13-
- uses: codespell-project/actions-codespell@v2
22+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
23+
with:
24+
persist-credentials: false
25+
- uses: codespell-project/actions-codespell@e3258cca84ce02b0bb36a3d41f2c18f719a0cc1a # v2.4.3
1426
with:
1527
check_filenames: true
1628
ignore_words_file: .codespellignore

‎.github/workflows/docusaurus.yml‎

Lines changed: 55 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,80 @@ name: Docusaurus site CI
22

33
on:
44
push:
5-
branches: [ master, upgrade ]
5+
branches: [ master ]
66
workflow_dispatch:
77

8+
permissions: {}
9+
10+
concurrency:
11+
group: ${{ github.workflow }}
12+
cancel-in-progress: false
13+
814
jobs:
915
build:
16+
name: Build
1017
runs-on: ubuntu-latest
18+
timeout-minutes: 20
19+
permissions:
20+
contents: read
1121
steps:
12-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
1323
with:
1424
fetch-depth: 0
25+
persist-credentials: false
1526

16-
- uses: actions/setup-node@v3
27+
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
1728
with:
18-
node-version: '21'
29+
node-version-file: .tool-versions
1930
cache: 'npm'
20-
- run: npm install
31+
- run: npm ci
2132
- run: npm run build
2233

34+
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
35+
with:
36+
name: site
37+
path: build/
38+
retention-days: 1
39+
if-no-files-found: error
40+
41+
deploy:
42+
name: Deploy
43+
needs: build
44+
runs-on: ubuntu-latest
45+
timeout-minutes: 15
46+
environment: production
47+
permissions: {}
48+
steps:
49+
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
50+
with:
51+
name: site
52+
path: build/
53+
2354
- name: Tailscale
24-
uses: tailscale/github-action@v2
55+
uses: tailscale/github-action@064b10558093f38325e838ddea35486bdc6b1d5c # v4.4.0
2556
with:
2657
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
2758
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
28-
version: '1.50.1'
2959
tags: tag:static-sites
3060

3161
- name: Deploy to Static Sites Host
32-
uses: burnett01/rsync-deployments@6.0.0
33-
with:
34-
switches: -avzr --delete
35-
path: build/
36-
remote_path: /var/www/docs/
37-
remote_host: ${{ secrets.DEPLOY_STATIC_SITE_HOST }}
38-
remote_user: ${{ secrets.DEPLOY_STATIC_SITE_USER }}
39-
remote_key: ${{ secrets.DEPLOY_STATIC_SITE_KEY }}
62+
env:
63+
DEPLOY_HOST: ${{ secrets.DEPLOY_STATIC_SITE_HOST }}
64+
DEPLOY_USER: ${{ secrets.DEPLOY_STATIC_SITE_USER }}
65+
DEPLOY_KNOWN_HOSTS: ${{ vars.DEPLOY_STATIC_SITE_KNOWN_HOSTS }}
66+
run: |
67+
test -n "$DEPLOY_KNOWN_HOSTS" || { echo "::error::DEPLOY_STATIC_SITE_KNOWN_HOSTS is not set"; exit 1; }
68+
install -m 700 -d ~/.ssh
69+
printf '%s\n' "$DEPLOY_KNOWN_HOSTS" > ~/.ssh/known_hosts
70+
rsync -avzr --delete \
71+
-e "ssh -o BatchMode=yes -o HostKeyAlias=static-sites -o StrictHostKeyChecking=yes" \
72+
build/ "$DEPLOY_USER@$DEPLOY_HOST:/var/www/docs/"
4073
4174
- name: Purge BunnyCDN cache
42-
uses: eayllon/bunnycdn-purge-cache@253ab627f8e743b4d7f96e7020e8bc04377ac49d
43-
with:
44-
accessKey: ${{ secrets.BUNNY_API_KEY }}
45-
zoneID: ${{ secrets.BUNNY_ZONE_ID }}
75+
env:
76+
BUNNY_API_KEY: ${{ secrets.BUNNY_API_KEY }}
77+
BUNNY_ZONE_ID: ${{ secrets.BUNNY_ZONE_ID }}
78+
run: |
79+
printf 'AccessKey: %s\n' "$BUNNY_API_KEY" |
80+
curl -sS --fail-with-body --proto '=https' --max-time 60 -X POST -H @- \
81+
"https://api.bunny.net/pullzone/$BUNNY_ZONE_ID/purgeCache"

0 commit comments

Comments
 (0)