-
Notifications
You must be signed in to change notification settings - Fork 3
110 lines (90 loc) · 3.14 KB
/
Copy pathdeploy-config-schema.yml
File metadata and controls
110 lines (90 loc) · 3.14 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
name: Deploy config schema
on:
push:
branches:
- main
paths:
- config/pkl/**
- .github/workflows/deploy-config-schema.yml
workflow_dispatch:
permissions:
contents: read
concurrency:
group: deploy-config-schema
cancel-in-progress: false
jobs:
deploy:
name: Deploy config schema to config.sce.crocoder.dev
timeout-minutes: 60
runs-on: ubuntu-latest
env:
VERCEL_CLI_VERSION: 58.7.1
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@05e31511f85b41b11d1cf0ef85d0992719546e2c # v2.21.0
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 24
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@ef8a148080ab6020fd15196c2084a2eea5ff2d25 # v22
- name: Enable Magic Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@908b263ff629f4cc17666315b7fd3ec127c6244d # v14
with:
use-flakehub: false
use-gha-cache: true
- name: Ensure Vercel deployment secrets are configured
shell: bash
run: |
set -euo pipefail
missing=""
for name in VERCEL_TOKEN VERCEL_ORG_ID VERCEL_PROJECT_ID; do
if [ -z "${!name:-}" ]; then
missing="${missing} ${name}"
fi
done
if [ -n "$missing" ]; then
printf 'Missing required repository secret(s):%s\n' "$missing" >&2
exit 1
fi
- name: Generate the canonical config schema
shell: bash
run: |
set -euo pipefail
staging_dir="${RUNNER_TEMP}/config-schema-site"
schema_module="${RUNNER_TEMP}/config-schema-deploy.pkl"
mkdir -p "$staging_dir"
cat > "$schema_module" <<EOF
module deploy.schema
import "file://${GITHUB_WORKSPACE}/config/pkl/base/sce-config-schema.pkl" as schema
output {
files {
["config.json"] {
text = schema.rendered
}
}
}
EOF
nix develop -c pkl eval -m "$staging_dir" "$schema_module" >/dev/null
file_count="$(find "$staging_dir" -type f | wc -l)"
if [ "$file_count" -ne 1 ] || [ ! -f "${staging_dir}/config.json" ]; then
printf 'Deployment staging must contain only config.json\n' >&2
find "$staging_dir" -type f -print >&2
exit 1
fi
printf 'STAGING_DIR=%s\n' "$staging_dir" >> "$GITHUB_ENV"
- name: Deploy the schema to Vercel
shell: bash
run: |
set -euo pipefail
npx --yes "vercel@${VERCEL_CLI_VERSION}" deploy "$STAGING_DIR" \
--prod \
--yes \
--token "$VERCEL_TOKEN"