From c1d6f15da4f129977613f61d61714fa56d3df7ae Mon Sep 17 00:00:00 2001 From: Stan <26458805+Staninna@users.noreply.github.com> Date: Wed, 27 Aug 2025 15:21:36 +0200 Subject: [PATCH 1/3] Create cd --- .github/workflows/cd | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/cd diff --git a/.github/workflows/cd b/.github/workflows/cd new file mode 100644 index 0000000..a4ac8e8 --- /dev/null +++ b/.github/workflows/cd @@ -0,0 +1,48 @@ +name: Pages – per-branch static + +on: + push: + branches-ignore: + - gh-pages + workflow_dispatch: + +permissions: + contents: write + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Sanitize branch name + id: br + shell: bash + run: | + SAFE="$(echo "${GITHUB_REF_NAME}" \ + | tr '/:@ ' '----' \ + | sed 's/[^A-Za-z0-9._-]/-/g')" + echo "safe=$SAFE" >> "$GITHUB_OUTPUT" + + - name: Stage only static files + run: | + mkdir -p _site + rsync -a --prune-empty-dirs \ + --include='*/' \ + --include='*.html' \ + --include='*.css' \ + --include='*.js' \ + --include='*.json' \ + --exclude='*' \ + ./ _site/ + + - name: Deploy to gh-pages/ + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_branch: gh-pages + publish_dir: _site + destination_dir: ${{ steps.br.outputs.safe }} + keep_files: true + commit_message: Deploy ${{ github.ref_name }} From a8cfe7f4a5a29d4f91d6806f9231b410f08876d4 Mon Sep 17 00:00:00 2001 From: Stan <26458805+Staninna@users.noreply.github.com> Date: Wed, 27 Aug 2025 15:23:20 +0200 Subject: [PATCH 2/3] Rename cd to cd.yml --- .github/workflows/{cd => cd.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{cd => cd.yml} (100%) diff --git a/.github/workflows/cd b/.github/workflows/cd.yml similarity index 100% rename from .github/workflows/cd rename to .github/workflows/cd.yml From 47137af1a17e19b570af6ca43706fef95bdfb082 Mon Sep 17 00:00:00 2001 From: Stan <26458805+Staninna@users.noreply.github.com> Date: Wed, 27 Aug 2025 15:41:37 +0200 Subject: [PATCH 3/3] Update cd.yml --- .github/workflows/cd.yml | 90 ++++++++++++++++++++++++++-------------- 1 file changed, 59 insertions(+), 31 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index a4ac8e8..c77e2e1 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -1,48 +1,76 @@ -name: Pages – per-branch static +name: Pages – aggregate all branches on: push: - branches-ignore: - - gh-pages + branches: ["**"] workflow_dispatch: permissions: - contents: write + contents: read + pages: write + id-token: write + +concurrency: + group: pages + cancel-in-progress: true jobs: - deploy: + aggregate_deploy: runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deploy.outputs.page_url }} steps: - - name: Checkout + - name: Checkout (shallow) uses: actions/checkout@v4 + with: + fetch-depth: 1 - - name: Sanitize branch name - id: br + - name: Configure Pages + uses: actions/configure-pages@v5 + + - name: Aggregate files from all branches into ./public shell: bash run: | - SAFE="$(echo "${GITHUB_REF_NAME}" \ - | tr '/:@ ' '----' \ - | sed 's/[^A-Za-z0-9._-]/-/g')" - echo "safe=$SAFE" >> "$GITHUB_OUTPUT" + set -euo pipefail + mkdir -p public - - name: Stage only static files - run: | - mkdir -p _site - rsync -a --prune-empty-dirs \ - --include='*/' \ - --include='*.html' \ - --include='*.css' \ - --include='*.js' \ - --include='*.json' \ - --exclude='*' \ - ./ _site/ + # List remote branches (exclude HEAD pointer) + mapfile -t BRANCHES < <(git ls-remote --heads origin \ + | awk '{print $2}' | sed 's@refs/heads/@@') - - name: Deploy to gh-pages/ - uses: peaceiris/actions-gh-pages@v4 + # Minimal index page + cat > public/index.html <<'HTML' + + Branches

Branches

" >> public/index.html + echo "Built public/ for ${#BRANCHES[@]} branches." + + - name: Upload Pages artifact + uses: actions/upload-pages-artifact@v4 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_branch: gh-pages - publish_dir: _site - destination_dir: ${{ steps.br.outputs.safe }} - keep_files: true - commit_message: Deploy ${{ github.ref_name }} + path: public + + - name: Deploy to GitHub Pages + id: deploy + uses: actions/deploy-pages@v4