Repository navigation
127 lines (108 loc) · 3.88 KB
/
Copy pathdocumentation.yml
File metadata and controls
127 lines (108 loc) · 3.88 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
name: Documentation
on:
workflow_dispatch:
inputs:
purge:
description: "Purge existing bundles and regenerate from scratch"
type: boolean
default: false
schedule:
# Run once every week on Sunday
- cron: 0 0 * * 0
push:
paths:
# Or if an include has been updated
- 'manifests/*.toml'
# Manual trigger
- 'trigger.txt'
env:
# sourcemod-dev/docgen commit chumbucket is built from
# Bundles are purged and regenerated from scratch whenever this changes
DOCGEN_REF: "9c54a72a1e69fae15cb9b6615cd6615731652f0c"
permissions:
contents: write
jobs:
documentation:
name: Build Documentations
runs-on: ubuntu-latest
steps:
- name: Checkout manifests
uses: actions/checkout@v4
with:
ref: "master"
path: "manifests"
- name: Checkout bundles
uses: actions/checkout@v4
with:
ref: "bundles"
path: "bundles"
- name: Checkout docgen
uses: actions/checkout@v4
with:
repository: "sourcemod-dev/docgen"
ref: ${{ env.DOCGEN_REF }}
path: "docgen"
persist-credentials: false
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
workspaces: "docgen"
- name: Build Chumbucket
working-directory: docgen
run: |
cargo build --release --locked -p chumbucket
cp target/release/chumbucket ../chumbucket
- name: Purge bundles
env:
PURGE: ${{ inputs.purge }}
run: |
# Bundles from an older docgen are not continued from, as their history and dates may differ
if [ "$PURGE" = "true" ] || [ "$(cat bundles/.docgen 2>/dev/null)" != "$DOCGEN_REF" ]; then
echo "Purging existing bundles"
rm -f bundles/*.bundle bundles/index
fi
echo "$DOCGEN_REF" > bundles/.docgen
- name: Process manifests
run: |
for i in manifests/manifests/*.toml; do
[ -f "$i" ] || break
export manifest_file=$(basename -- "$i")
echo "Processing $manifest_file"
if [ -f "bundles/${manifest_file%.*}.bundle" ]; then
./chumbucket generate manifests/manifests/$manifest_file -b bundles/${manifest_file%.*}.bundle -o bundles/${manifest_file%.*}.bundle
else
./chumbucket generate manifests/manifests/$manifest_file -o bundles/${manifest_file%.*}.bundle
fi
done
ls -l bundles/
- name: Process bundle index
run: |
if [ -f "bundles/index" ]; then
./chumbucket build-index bundles -i bundles/index -o bundles/index
else
./chumbucket build-index bundles -o bundles/index
fi
- name: Commit changes
id: commit
working-directory: bundles
run: |
if [ -n "$(git status --porcelain)" ]; then
git config --global user.name 'rumblefrog'
git config --global user.email 'contact@rumblefrog.me'
git add -A
git commit -m 'Bundle generations'
git push
echo "committed=true" >> "$GITHUB_OUTPUT"
fi
- name: Purge jsDelivr cache
if: steps.commit.outputs.committed == 'true'
working-directory: bundles
run: |
# jsDelivr caches branch files, so purge every file changed by the bundle commit
git diff --name-only HEAD~1 HEAD | while read -r file; do
echo "Purging $file"
curl -fsS --retry 3 "https://purge.jsdelivr.net/gh/${GITHUB_REPOSITORY}@bundles/${file}"
echo
done