Repository navigation
99 lines (95 loc) · 3.53 KB
/
Copy pathbuild.yml
File metadata and controls
99 lines (95 loc) · 3.53 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
---
name: build
"on": push
# Nothing by default: each job asks for exactly what it uses.
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: build
runs-on: ubuntu-26.04
permissions:
contents: read # check out the repository
actions: write # delete a stale pages artifact (step below)
outputs:
pages-dir: ${{ steps.pages.outputs.dir }}
steps:
- uses: actions/checkout@v7
with:
# A no-op in repos without submodules, so every repo shares this
# exact file.
submodules: recursive
# The token is not left in .git/config for later steps to pick up;
# the steps that call the API get it through GH_TOKEN.
persist-credentials: false
- uses: actions/cache@v6
with:
path: .rsconstruct
# Primary key is unique per run so every successful run saves a fresh
# cache. restore-keys lets the run start from the most recent cache
# matching the prefix. Without this (static key), actions/cache never
# re-saves once the first cache exists.
key: rsconstruct-${{ runner.os }}-${{ github.run_id }}
restore-keys: |
rsconstruct-${{ runner.os }}-
- name: install rsconstruct
run: |
gh release download --repo veltzer/rsconstruct --pattern 'rsconstruct-linux-x86_64' \
--output /usr/local/bin/rsconstruct
chmod +x /usr/local/bin/rsconstruct
rsconstruct version
env:
GH_TOKEN: ${{ github.token }}
- name: install
run: |
rsconstruct tool install machine
rsconstruct tool install project
- name: build
run: rsconstruct build
env:
# Build steps that call the GitHub API (gh, release metadata
# downloads) authenticate with the job's own token instead of
# sharing the runner IP's anonymous rate limit.
GH_TOKEN: ${{ github.token }}
- name: status
run: rsconstruct status
- name: pages dir
# Empty when [pages] is not configured in rsconstruct.toml; the upload
# step and the deploy job skip on empty, which is what lets Pages and
# non-Pages repos share this exact file.
id: pages
run: echo "dir=$(rsconstruct page dir)" >> "$GITHUB_OUTPUT"
- name: delete stale pages artifact
# Artifacts survive re-run attempts, and both the upload and
# deploy-pages fail hard when a "github-pages" artifact already exists
# in the run. Delete any leftover from a previous attempt first.
if: steps.pages.outputs.dir != ''
run: |
gh api --paginate "repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/artifacts" \
--jq '.artifacts[] | select(.name == "github-pages") | .id' |
while read -r artifact_id; do
echo "deleting stale artifact ${artifact_id}"
gh api -X DELETE "repos/${GITHUB_REPOSITORY}/actions/artifacts/${artifact_id}"
done
env:
GH_TOKEN: ${{ github.token }}
- uses: actions/upload-pages-artifact@v5
if: steps.pages.outputs.dir != ''
with:
path: ${{ steps.pages.outputs.dir }}
deploy:
name: deploy
needs: build
if: needs.build.outputs.pages-dir != ''
runs-on: ubuntu-26.04
permissions:
pages: write # publish the site
id-token: write # prove to Pages that this run is the deployment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/deploy-pages@v5
id: deployment