This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/attic.git


The following commit(s) were added to refs/heads/main by this push:
     new a528a96  Use new branch for non-main branch builds
a528a96 is described below

commit a528a96d66ea3f75b40505e5be628f4002a7bb60
Author: Sebb <s...@apache.org>
AuthorDate: Sun May 4 14:25:09 2025 +0100

    Use new branch for non-main branch builds
    
    Also automatically stage the output.
    
    [skip ci]
---
 .github/workflows/website.yml | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml
index 7523021..1d4d164 100644
--- a/.github/workflows/website.yml
+++ b/.github/workflows/website.yml
@@ -96,12 +96,35 @@ jobs:
       - name: 🚀 Add commit to the branch (if not 'main')
         if: ${{ (github.head_ref || github.ref_name) != 'main' }}
         run: |
+          BRANCH="${{ (github.head_ref || github.ref_name) }}"
+          SITE="${{ (github.head_ref || github.ref_name) }}-site"
+          echo "branch: $BRANCH => site: $SITE"
           echo "Running git config"
           git config user.name "GitHub Actions"
           git config user.email "acti...@users.noreply.github.com"
-          # Allow branch to serve as staging site
+          # ensure access to existing branches (i.e. allow for depth=1)
+          git fetch --tags -- origin +refs/heads/*:refs/remotes/origin/*
+          if git switch $SITE
+          then
+            echo "updating existing $SITE"
+          else
+            echo "creating orphan $SITE"
+            git switch --orphan $SITE
+            # Need gitignore
+            git checkout ${BRANCH} -- .gitignore
+            # create staging site
+            {
+              echo "staging:"
+              echo "  profile: $BRANCH"
+              echo "  whoami: $SITE"
+            } >.asf.yaml
+            git add -A .
+            git commit -m "Init staging site $SITE"
+            git push --set-upstream origin $SITE
+          fi
           rm -rf output
           mv asf-site/output .
+          git add -f output # override .gitignore
           rm -rf asf-site
           echo "Running git add -A"
           git add -A .

Reply via email to