Skip to content

Web: Directory listing #50

Web: Directory listing

Web: Directory listing #50

name: "Web: Directory listing"
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 + upload artifact"
runs-on: ubuntu-24.04
# Loop guard: don't rerun on our own generated commit
if: ${{ 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/web-directory-listing.yml \
"$tmpdir/.github/workflows/web-directory-listing.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/web-directory-listing.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