Repository navigation
128 lines (121 loc) · 3.94 KB
/
Copy pathsite.yml
File metadata and controls
128 lines (121 loc) · 3.94 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
121
122
123
124
125
126
127
128
# Builds, tests and security-scans the Astro site, then deploys dist/ to
# GitHub Pages from main.
#
# - pull_request: security + build (no deploy)
# - push to main / manual run: security + build + deploy
# - weekly schedule: security + build only, so newly published CVEs in the
# lockfile fail a run even when nothing has been pushed
name: Site
on:
pull_request:
push:
branches: [main]
workflow_dispatch:
schedule:
- cron: '17 3 * * 1'
permissions: {}
concurrency:
group: site-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
ASTRO_TELEMETRY_DISABLED: '1'
HUSKY: '0'
jobs:
security:
name: CVE scan
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Node.js
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: .nvmrc
cache: npm
- name: Install dependencies
run: npm ci
- name: npm audit
run: npm run audit:npm
- name: Verify registry signatures and provenance
run: npm run audit:signatures
- name: OSV-Scanner
uses: google/osv-scanner-action/osv-scanner-action@32d3cd482bdadfb38b186c0ad1b031902d55d932 # v2.7.1
with:
scan-args: |-
--lockfile=package-lock.json
build:
name: Check, build and test
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Node.js
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: .nvmrc
cache: npm
- name: Install dependencies
run: npm ci
- name: Type-check, build and test
run: npm run verify
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
path: ./dist
retention-days: 1
deploy:
name: Deploy to Pages
needs: [security, build]
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && github.event_name != 'schedule'
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
pages: write
id-token: write
deployments: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
# One Pages deploy at a time; never cancel one that has started.
concurrency:
group: pages
cancel-in-progress: false
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1
- name: Clean up old deployments
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const deployments = await github.rest.repos.listDeployments({
owner: context.repo.owner,
repo: context.repo.repo,
environment: 'github-pages',
per_page: 100
});
const stale = deployments.data.slice(1);
for (const d of stale) {
await github.rest.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: d.id,
state: 'inactive'
});
await github.rest.repos.deleteDeployment({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: d.id
});
}
console.log(`Cleaned up ${stale.length} old deployments`);