1+ name : " Web: Generate github.armbian.com content"
2+
3+ on :
4+ push :
5+ branches : [data]
6+ workflow_dispatch :
7+ repository_dispatch :
8+ types : ["Web: Directory listing"]
9+
10+ permissions :
11+ contents : write
12+ pages : write
13+ id-token : write
14+
15+ concurrency :
16+ group : pages-data
17+ cancel-in-progress : true
18+
19+ jobs :
20+ build :
21+ name : " Rebuild data branch"
22+ runs-on : ubuntu-24.04
23+
24+ # Only run in Armbian organization
25+ # Loop guard: don't rerun on our own generated commit
26+ if : ${{ github.repository_owner == 'Armbian' && (github.event_name != 'push' || !contains(github.event.head_commit.message, 'Rebuild data branch (generated)')) }}
27+
28+ steps :
29+ - name : Checkout data branch
30+ uses : actions/checkout@v6
31+ with :
32+ ref : data
33+ fetch-depth : 0
34+ path : data_wd
35+
36+ - name : Checkout main branch (workflow source)
37+ uses : actions/checkout@v6
38+ with :
39+ ref : main
40+ fetch-depth : 0
41+ path : main_wd
42+
43+ - name : Stage generated data + updated workflow
44+ shell : bash
45+ run : |
46+ set -euo pipefail
47+ tmpdir="$(mktemp -d)"
48+
49+ # Keep generated content
50+ rsync -a data_wd/data/ "$tmpdir/data/"
51+
52+ # Keep the workflow file on data so pushes keep triggering,
53+ # and update it from main (because you edit only main).
54+ mkdir -p "$tmpdir/.github/workflows"
55+ rsync -a \
56+ main_wd/.github/workflows/generate-web-directory.yml \
57+ "$tmpdir/.github/workflows/generate-web-directory.yml"
58+
59+ echo "TMPDIR=$tmpdir" >> "$GITHUB_ENV"
60+
61+ - name : Rewrite data branch from scratch (single commit)
62+ shell : bash
63+ working-directory : data_wd
64+ run : |
65+ set -euo pipefail
66+
67+ git config user.name "github-actions"
68+ git config user.email "github-actions@github.com"
69+
70+ git checkout --orphan __data_rebuild__
71+ git rm -rf . >/dev/null 2>&1 || true
72+ git clean -fdx
73+
74+ mkdir -p data .github/workflows
75+ rsync -a --delete "$TMPDIR/data/" data/
76+ rsync -a --delete "$TMPDIR/.github/workflows/" .github/workflows/
77+
78+ git add data .github/workflows/generate-web-directory.yml
79+ git commit -m "Rebuild data branch (generated)"
80+ git branch -M data
81+ git push -f origin data
82+
83+ - name : Generate Directory Listings
84+ uses : jayanta525/github-pages-directory-listing@v4.0.0
85+ with :
86+ FOLDER : " data_wd/data"
87+
88+ - name : Upload Pages artifact
89+ uses : actions/upload-pages-artifact@v5
90+ with :
91+ path : " data_wd/data"
92+
93+ deploy :
94+ name : " Deploy to armbian.github.io"
95+ needs : build
96+ permissions :
97+ pages : write
98+ id-token : write
99+ environment :
100+ name : github-pages
101+ url : ${{ steps.deployment.outputs.page_url }}
102+ runs-on : ubuntu-24.04
103+ steps :
104+ - name : Deploy to GitHub Pages
105+ id : deployment
106+ uses : actions/deploy-pages@v5
107+
108+ - name : Install SSH key + known_hosts (task two)
109+ uses : shimataro/ssh-key-action@v2
110+ with :
111+ key : ${{ secrets.KEY_REDI_TASK_ONE }}
112+ known_hosts : ${{ secrets.KNOWN_HOSTS_REDI }}
113+ name : redi_task_one
114+
115+ - name : Reload redirector
116+ shell : bash
117+ env :
118+ REDI_HOST : " redi@${{ secrets.HOST_REDI }}" # e.g. user@host
119+ REDI_PORT : 22 # optional
120+ run : |
121+ set -euo pipefail
122+ PORT="${REDI_PORT:-22}"
123+ : "${REDI_HOST:?Set vars.REDI_HOST (e.g. user@host)}"
124+ ssh \
125+ -i ~/.ssh/redi_task_one \
126+ -p "$PORT" \
127+ -o BatchMode=yes \
128+ -o IdentitiesOnly=yes \
129+ -o StrictHostKeyChecking=yes \
130+ -o UserKnownHostsFile=~/.ssh/known_hosts \
131+ "$REDI_HOST" </dev/null
0 commit comments