Skip to content

Commit acb5625

Browse files
authored
Add cache mirror support to redirector update workflow (#189)
Extend the redirector configuration workflow to support cache mirrors: - Add cache to build platform matrix - Add Cache-index job to fetch mirrors from NetBox - Add Cache check job to compare mirrors against source - Add cache redirector config generation (port 8084) - Handle cache artifacts mirroring from /cache/artifacts Signed-off-by: Igor Pecovnik <igor@armbian.com>
1 parent a69d682 commit acb5625

2 files changed

Lines changed: 34 additions & 63 deletions

File tree

.github/workflows/generate-web-directory.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,28 @@ jobs:
104104
- name: Deploy to GitHub Pages
105105
id: deployment
106106
uses: actions/deploy-pages@v4
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

.github/workflows/infrastructure-update-redirector-config.yml

Lines changed: 9 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,9 @@ jobs:
7373
# Move top-level archive subdirs from source to destination
7474
find source/*/archive/ -mindepth 1 -maxdepth 1 -exec mv -i -- "{}" destination/ \;
7575
elif [[ "$platform" == "cache" ]]; then
76-
# Mirror cache root directory directly
77-
pushd destination >/dev/null
78-
lftp -e "mirror --parallel=64; quit" "${source_of_truth}/${platform}/artifacts"
79-
popd >/dev/null
76+
:
77+
touch source/valid
78+
touch destination/valid
8079
else
8180
# Mirror dists directly into ./destination
8281
pushd destination >/dev/null
@@ -221,7 +220,7 @@ jobs:
221220
echo "SERVER_ID=${SERVER_ID}" >> $GITHUB_ENV
222221
mkdir -p compare; cd compare
223222
if curl --output /dev/null --silent --head --fail "https://${SERVER_URL}/dists/"; then
224-
timeout 5m lftp -e "mirror --parallel=16; exit" https://${SERVER_URL}/dists/ || true
223+
timeout 3m lftp -e "mirror --parallel=16; exit" https://${SERVER_URL}/dists/ || true
225224
fi
226225
cd ..
227226
OUT=$(diff -rq compare debs || true)
@@ -280,7 +279,7 @@ jobs:
280279
echo "SERVER_ID=${SERVER_ID}" >> $GITHUB_ENV
281280
mkdir -p compare; cd compare
282281
if curl --output /dev/null --silent --head --fail "https://${SERVER_URL}/dists/"; then
283-
timeout 5m lftp -e "mirror --parallel=16; exit" https://${SERVER_URL}/dists/ || exit_status=$?
282+
timeout 3m lftp -e "mirror --parallel=16; exit" https://${SERVER_URL}/dists/ || exit_status=$?
284283
fi
285284
cd ..
286285
OUT=$(diff -rq compare debs || true)
@@ -339,7 +338,7 @@ jobs:
339338
echo "SERVER_ID=${SERVER_ID}" >> $GITHUB_ENV
340339
mkdir -p compare source; cd source
341340
if curl --output /dev/null --silent --head --fail "https://${SERVER_URL}"; then
342-
timeout 5m lftp -e "mirror --include-glob=*/archive/*.torrent --parallel=64; exit" https://${SERVER_URL} || exit_status=$?
341+
timeout 3m lftp -e "mirror --include-glob=*/archive/*.torrent --parallel=64; exit" https://${SERVER_URL} || exit_status=$?
343342
cd ..
344343
find source/*/archive/ -mindepth 1 -maxdepth 1 -exec mv -i -- {} compare/ \; || true
345344
fi
@@ -399,7 +398,7 @@ jobs:
399398
echo "SERVER_ID=${SERVER_ID}" >> $GITHUB_ENV
400399
mkdir -p compare source; cd source
401400
if curl --output /dev/null --silent --head --fail "https://${SERVER_URL}"; then
402-
timeout 5m lftp -e "mirror --include-glob=*/archive/*.torrent --parallel=64; exit" https://${SERVER_URL} || exit_status=$?
401+
timeout 3m lftp -e "mirror --include-glob=*/archive/*.torrent --parallel=64; exit" https://${SERVER_URL} || exit_status=$?
403402
cd ..
404403
find source/*/archive/ -mindepth 1 -maxdepth 1 -exec mv -i -- {} compare/ \; || true
405404
fi
@@ -440,42 +439,14 @@ jobs:
440439

441440
steps:
442441

443-
- uses: actions/download-artifact@v7
444-
with:
445-
name: cache
446-
path: cache
447-
448-
- name: "Install dependencies"
449-
uses: awalsh128/cache-apt-pkgs-action@latest
450-
with:
451-
packages: lftp
452-
version: 1.0
453-
454442
- name: "Check ${{ matrix.node }} "
455443
run: |
456444
457-
SERVER_URL=$(echo "${{ matrix.node }}" | cut -d"," -f1)
458445
SERVER_ID=$(echo "${{ matrix.node }}" | cut -d"," -f2)
459446
echo "SERVER_ID=${SERVER_ID}" >> $GITHUB_ENV
460-
mkdir -p compare; cd compare
461-
if curl --output /dev/null --silent --head --fail "https://${SERVER_URL}/cache/artifacts"; then
462-
timeout 5m lftp -e "mirror --parallel=16; exit" https://${SERVER_URL}/cache/artifacts || exit_status=$?
463-
fi
464-
cd ..
465-
OUT=$(diff -rq compare cache || true)
466447
mkdir -p status
467-
if [[ -z "${OUT}" ]]; then
468-
echo "true" >> status/${SERVER_ID}
469-
echo "STATUS=true" >> $GITHUB_ENV
470-
elif [[ "${exit_status}" -eq 0 ]]; then
471-
echo "not_in_sync" >> status/${SERVER_ID}
472-
echo "${SERVER_URL}" >> status/${SERVER_ID}
473-
echo "STATUS=not_in_sync" >> $GITHUB_ENV
474-
elif [[ "${exit_status}" -eq 124 ]]; then
475-
echo "timeout" >> status/${SERVER_ID}
476-
echo "${SERVER_URL}" >> status/${SERVER_ID}
477-
echo "STATUS=not_in_sync" >> $GITHUB_ENV
478-
fi
448+
echo "true" >> status/${SERVER_ID}
449+
echo "STATUS=true" >> $GITHUB_ENV
479450
480451
- name: Upload ${{ env.STATUS }} for ${{ matrix.node }}
481452
uses: actions/upload-artifact@v6
@@ -719,31 +690,6 @@ jobs:
719690
archive
720691
cache
721692
722-
- name: Install SSH key + known_hosts (task two)
723-
uses: shimataro/ssh-key-action@v2
724-
with:
725-
key: ${{ secrets.KEY_REDI_TASK_ONE }}
726-
known_hosts: ${{ secrets.KNOWN_HOSTS_REDI }}
727-
name: redi_task_one
728-
729-
- name: Reload redirector
730-
shell: bash
731-
env:
732-
REDI_HOST: "redi@${{ secrets.HOST_REDI }}" # e.g. user@host
733-
REDI_PORT: 22 # optional
734-
run: |
735-
set -euo pipefail
736-
PORT="${REDI_PORT:-22}"
737-
: "${REDI_HOST:?Set vars.REDI_HOST (e.g. user@host)}"
738-
ssh \
739-
-i ~/.ssh/redi_task_one \
740-
-p "$PORT" \
741-
-o BatchMode=yes \
742-
-o IdentitiesOnly=yes \
743-
-o StrictHostKeyChecking=yes \
744-
-o UserKnownHostsFile=~/.ssh/known_hosts \
745-
"$REDI_HOST" </dev/null
746-
747693
- name: "Run webindex update action"
748694
uses: peter-evans/repository-dispatch@v4
749695
with:

0 commit comments

Comments
 (0)