-
Notifications
You must be signed in to change notification settings - Fork 19
135 lines (115 loc) · 4.59 KB
/
deploy.yml
File metadata and controls
135 lines (115 loc) · 4.59 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
129
130
131
132
133
134
135
name: Deploy to GitHub Pages
on:
push:
branches: [main]
paths:
- 'content/**'
- 'translations/**'
- 'templates/**'
- 'site/**'
- 'html-generators/generateog.java'
- 'html-generators/og/**'
workflow_run:
workflows: ['Build Generator JARs']
types: [completed]
branches: [main]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 2
- name: Detect changed paths
id: changes
run: |
# OG images are gitignored and must always be regenerated
echo "og=true" >> "$GITHUB_OUTPUT"
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "generate=true" >> "$GITHUB_OUTPUT"
elif [[ "${{ github.event_name }}" == "workflow_run" ]]; then
# Generator JAR was rebuilt — regenerate HTML
echo "generate=true" >> "$GITHUB_OUTPUT"
else
# Push event — check which files changed
CHANGED=$(git diff --name-only HEAD~1 HEAD)
echo "Changed files:"
echo "$CHANGED"
NEEDS_GENERATE=false
if echo "$CHANGED" | grep -qE '^(content/|translations/|templates/)'; then
NEEDS_GENERATE=true
fi
echo "generate=$NEEDS_GENERATE" >> "$GITHUB_OUTPUT"
fi
echo "Summary: generate=${{ steps.changes.outputs.generate || 'pending' }}, og=${{ steps.changes.outputs.og || 'pending' }}"
- uses: actions/setup-java@v5
if: steps.changes.outputs.generate == 'true' || steps.changes.outputs.og == 'true'
with:
distribution: 'temurin'
java-version: '25'
# --- HTML generation (content/templates/translations changed) ---
- name: Restore cached generate JAR and AOT
id: cache-restore
if: steps.changes.outputs.generate == 'true'
uses: actions/cache/restore@v5
with:
path: |
html-generators/generate.jar
html-generators/generate.aot
key: generator-${{ hashFiles('html-generators/generate.java') }}
- name: Generate HTML with cached JAR + AOT
if: steps.changes.outputs.generate == 'true' && steps.cache-restore.outputs.cache-hit == 'true'
run: java -XX:Tier4CompileThreshold=100 -XX:AOTCache=html-generators/generate.aot -jar html-generators/generate.jar
- name: Setup JBang (cache miss)
if: steps.changes.outputs.generate == 'true' && steps.cache-restore.outputs.cache-hit != 'true'
uses: jbangdev/setup-jbang@main
- name: Generate HTML with JBang (cache miss)
if: steps.changes.outputs.generate == 'true' && steps.cache-restore.outputs.cache-hit != 'true'
run: jbang html-generators/generate.java
# --- OG card generation (content/templates/translations or generateog.java changed) ---
- name: Restore cached generateog JAR and AOT
id: cache-restore-og
if: steps.changes.outputs.og == 'true'
uses: actions/cache/restore@v5
with:
path: |
html-generators/generateog.jar
html-generators/generateog.aot
key: generateog-${{ hashFiles('html-generators/generateog.java') }}
- name: Generate OG cards with cached JAR + AOT
if: steps.changes.outputs.og == 'true' && steps.cache-restore-og.outputs.cache-hit == 'true'
run: java -XX:Tier4CompileThreshold=100 -XX:AOTCache=html-generators/generateog.aot -jar html-generators/generateog.jar
- name: Generate OG cards with JBang (cache miss)
if: steps.changes.outputs.og == 'true' && steps.cache-restore-og.outputs.cache-hit != 'true'
run: |
if ! command -v jbang &> /dev/null; then
echo "Installing JBang..."
curl -Ls https://sh.jbang.dev | bash -s - app setup
export PATH="$HOME/.jbang/bin:$PATH"
fi
jbang html-generators/generateog.java
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v4
with:
path: site
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4