-
-
Notifications
You must be signed in to change notification settings - Fork 29
131 lines (110 loc) · 3.73 KB
/
generate-web-directory.yml
File metadata and controls
131 lines (110 loc) · 3.73 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
name: "Web: Generate github.armbian.com content"
on:
push:
branches: [data]
workflow_dispatch:
repository_dispatch:
types: ["Web: Directory listing"]
permissions:
contents: write
pages: write
id-token: write
concurrency:
group: pages-data
cancel-in-progress: true
jobs:
build:
name: "Rebuild data branch"
runs-on: ubuntu-24.04
# Only run in Armbian organization
# Loop guard: don't rerun on our own generated commit
if: ${{ github.repository_owner == 'Armbian' && (github.event_name != 'push' || !contains(github.event.head_commit.message, 'Rebuild data branch (generated)')) }}
steps:
- name: Checkout data branch
uses: actions/checkout@v6
with:
ref: data
fetch-depth: 0
path: data_wd
- name: Checkout main branch (workflow source)
uses: actions/checkout@v6
with:
ref: main
fetch-depth: 0
path: main_wd
- name: Stage generated data + updated workflow
shell: bash
run: |
set -euo pipefail
tmpdir="$(mktemp -d)"
# Keep generated content
rsync -a data_wd/data/ "$tmpdir/data/"
# Keep the workflow file on data so pushes keep triggering,
# and update it from main (because you edit only main).
mkdir -p "$tmpdir/.github/workflows"
rsync -a \
main_wd/.github/workflows/generate-web-directory.yml \
"$tmpdir/.github/workflows/generate-web-directory.yml"
echo "TMPDIR=$tmpdir" >> "$GITHUB_ENV"
- name: Rewrite data branch from scratch (single commit)
shell: bash
working-directory: data_wd
run: |
set -euo pipefail
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git checkout --orphan __data_rebuild__
git rm -rf . >/dev/null 2>&1 || true
git clean -fdx
mkdir -p data .github/workflows
rsync -a --delete "$TMPDIR/data/" data/
rsync -a --delete "$TMPDIR/.github/workflows/" .github/workflows/
git add data .github/workflows/generate-web-directory.yml
git commit -m "Rebuild data branch (generated)"
git branch -M data
git push -f origin data
- name: Generate Directory Listings
uses: jayanta525/github-pages-directory-listing@v4.0.0
with:
FOLDER: "data_wd/data"
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v5
with:
path: "data_wd/data"
deploy:
name: "Deploy to armbian.github.io"
needs: build
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-24.04
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
- name: Install SSH key + known_hosts (task two)
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.KEY_REDI_TASK_ONE }}
known_hosts: ${{ secrets.KNOWN_HOSTS_REDI }}
name: redi_task_one
- name: Reload redirector
shell: bash
env:
REDI_HOST: "redi@${{ secrets.HOST_REDI }}" # e.g. user@host
REDI_PORT: 22 # optional
run: |
set -euo pipefail
PORT="${REDI_PORT:-22}"
: "${REDI_HOST:?Set vars.REDI_HOST (e.g. user@host)}"
ssh \
-i ~/.ssh/redi_task_one \
-p "$PORT" \
-o BatchMode=yes \
-o IdentitiesOnly=yes \
-o StrictHostKeyChecking=yes \
-o UserKnownHostsFile=~/.ssh/known_hosts \
"$REDI_HOST" </dev/null