Skip to content

Web: Directory listing #929

Web: Directory listing

Web: Directory listing #929

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@v4
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@v4
- 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