Repository navigation
99 lines (89 loc) · 3.68 KB
/
Copy pathdeploy.yml
File metadata and controls
99 lines (89 loc) · 3.68 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
# Build the site and sync it to Bunny, uploading only what changed.
#
# Runs on every push to main once the repository variable DEPLOY_ENABLED is
# "true"; until then only by hand (Actions → Deploy → Run workflow), where it
# defaults to a dry run that prints the plan without touching Bunny.
#
# Secrets (Prod environment): BUNNY_STORAGE_ZONE, BUNNY_STORAGE_KEY, BUNNY_API_KEY.
# Variables (Prod environment): BUNNY_STORAGE_HOST (e.g. syd.storage.bunnycdn.com),
# BUNNY_PULL_ZONE_ID. Repository variable: DEPLOY_ENABLED.
name: Deploy
on:
push:
branches: [main]
workflow_dispatch:
inputs:
dry_run:
description: Dry run (print what would change, upload nothing)
type: boolean
default: true
# One deploy at a time, in order; never cancel one halfway through an upload.
concurrency:
group: deploy
cancel-in-progress: false
permissions:
contents: read
jobs:
deploy:
# Only main ever reaches the live site, even from a manual run.
if: github.ref == 'refs/heads/main' && (github.event_name == 'workflow_dispatch' || vars.DEPLOY_ENABLED == 'true')
# The Bunny secrets and variables live in the Prod environment. DEPLOY_ENABLED
# must stay a repository variable: the job's `if` runs before the
# environment loads, so it can't see environment variables.
environment: Prod
# macOS: the build is Swift, and link cards are drawn with AppKit.
runs-on: macos-15
timeout-minutes: 45
steps:
- uses: actions/checkout@v7
- name: Use the newest release Xcode on the runner (no betas or RCs)
run: |
sudo xcode-select -s "$(ls -d /Applications/Xcode_*.app | grep -viE 'beta|_rc|release.candidate' | sort -V | tail -1)"
swift --version
- uses: actions/setup-python@v7
with:
python-version: "3.14"
- run: python -m pip install --quiet -r requirements.txt
# Caches only make the build faster: a cold run produces the same bytes,
# so a cache miss never means a bigger upload.
- name: Restore Swift build
uses: actions/cache@v6
with:
path: |
.build
!.build/link-cards
key: swiftpm-${{ runner.os }}-${{ hashFiles('Package.resolved', 'Package.swift', 'Sources/**/*.swift') }}
restore-keys: swiftpm-${{ runner.os }}-
- name: Restore image variants
uses: actions/cache@v6
with:
path: |
Assets/img/**/*@*w.*
.media-cache.json
key: media-${{ github.run_id }}
restore-keys: media-
- name: Restore link cards
uses: actions/cache@v6
with:
path: .build/link-cards
key: link-cards-${{ github.run_id }}
restore-keys: link-cards-
- name: Build and check
run: bash Scripts/build.sh
- name: Tests
run: |
python -m unittest discover -s Scripts/tests -p '*_test.py'
node --test Scripts/tests/frontend_navigation_test.cjs
swift test --disable-automatic-resolution
- name: Deploy
env:
BUNNY_STORAGE_ZONE: ${{ secrets.BUNNY_STORAGE_ZONE }}
BUNNY_STORAGE_KEY: ${{ secrets.BUNNY_STORAGE_KEY }}
BUNNY_API_KEY: ${{ secrets.BUNNY_API_KEY }}
BUNNY_STORAGE_HOST: ${{ vars.BUNNY_STORAGE_HOST }}
BUNNY_PULL_ZONE_ID: ${{ vars.BUNNY_PULL_ZONE_ID }}
DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run && '--dry-run' || '' }}
shell: bash # -o pipefail, so a failed deploy isn't hidden by tee
run: |
python Scripts/deploy-bunny.py $DRY_RUN | tee deploy.log
{ echo '```'; head -c 60000 deploy.log; echo '```'; } >> "$GITHUB_STEP_SUMMARY"