Skip to content

Generate directory #3215

Generate directory

Generate directory #3215

name: "Generate directory listing"
on:
repository_dispatch:
types: ["Generate directory"]
workflow_dispatch:
permissions:
contents: write # needed to force-push to data
pages: write # deploy to Pages
id-token: write # verify deployment source
jobs:
pages-directory-listing:
runs-on: ubuntu-24.04
name: "Directory Listings Index"
steps:
- name: Checkout data branch
uses: actions/checkout@v5
with:
ref: data
fetch-depth: 0
- name: Generate Directory Listings
uses: jayanta525/[email protected]
with:
FOLDER: data
# --- Rewrite data branch as a fresh single-commit state (drop history) ---
- name: Force-rewrite data branch (orphan)
shell: bash
run: |
set -euo pipefail
# Keep a copy of /data (generated listing included)
tmpdir="$(mktemp -d)"
rsync -a --delete data/ "$tmpdir/"
# Create an orphan branch and replace contents with only /data
git config user.name "github-actions"
git config user.email "[email protected]"
# If we are already on data, switch to a temporary orphan first
git checkout --orphan tmp-data-rewrite
# Remove all tracked files from index & workspace
git reset --hard
git rm -rf . >/dev/null 2>&1 || true
git clean -fdx
# Restore just the data/ directory
mkdir -p data
rsync -a --delete "$tmpdir/" "data/"
# Commit and replace the branch
git add data
git commit -m "Recreate data branch with generated directory listing (history dropped)"
git branch -M data
git push -f origin data
- name: Upload artifact
uses: actions/upload-pages-artifact@v4
with:
path: 'data' # upload generated folder
deploy:
needs: pages-directory-listing
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