You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by mg...@apache.org on 2023/01/03 19:42:16 UTC

[avro] 01/01: AVRO-3686: Automate the creation of the target site branch

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

mgrigorov pushed a commit to branch avro-3686-asf.yaml-docs
in repository https://gitbox.apache.org/repos/asf/avro.git

commit 22b517f746dca536a599e7e23f4dcc9efc6f6e44
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
AuthorDate: Tue Dec 20 15:58:54 2022 +0200

    AVRO-3686: Automate the creation of the target site branch
    
    Signed-off-by: Martin Tzvetanov Grigorov <mg...@apache.org>
---
 .asf.yaml                   |  4 ++--
 .github/workflows/docs.yaml | 50 ++++++++++++++++++++++-----------------------
 2 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/.asf.yaml b/.asf.yaml
index 8580b6ab8..876182e6d 100644
--- a/.asf.yaml
+++ b/.asf.yaml
@@ -50,5 +50,5 @@ notifications:
   jira_options: link label worklog
 
 publish:
-  whoami: site-staging
-  subdir: next
+  whoami: TARGET_BRANCH
+  subdir: SUBDIR
diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml
index 9b36c6cef..cad050d4e 100644
--- a/.github/workflows/docs.yaml
+++ b/.github/workflows/docs.yaml
@@ -21,6 +21,7 @@ on:
   push:
     branches:
 #      - master
+      - branch-1.11.x
       - "avro-3686-asf.yaml-docs"
     tags-ignore:
       - "release-**-rc**"
@@ -33,13 +34,20 @@ jobs:
   build-docs:
     runs-on: ubuntu-20.04
     steps:
-      - name: Set target branch
+      - name: Checkout project
+        uses: actions/checkout@v3
+        with:
+          submodules: recursive
+
+      - name: Set variables
         id: variables
         run: |
           set -x
-          if test '${{ github.ref }}' = 'refs/heads/avro-3686-asf.yaml-docs'; then
-            echo "target-branch=site-staging" >> $GITHUB_OUTPUT
-            echo "baseUrl=/next" >> $GITHUB_OUTPUT
+          VERSION=$(cat share/VERSION.txt)
+          echo "version=$VERSION" >> $GITHUB_OUTPUT
+          if test '${{ github.ref_type }}' = 'branch'; then
+            echo "target-branch=site-$VERSION" >> $GITHUB_OUTPUT
+            echo "baseUrl=/$VERSION" >> $GITHUB_OUTPUT
           elif test '${{ github.ref_type }}' = 'tag'; then
             echo "target-branch=site-production" >> $GITHUB_OUTPUT
             echo "baseUrl=/" >> $GITHUB_OUTPUT
@@ -48,18 +56,6 @@ jobs:
             exit 1
           fi
 
-      - name: Checkout docs sources
-        uses: actions/checkout@v3
-        with:
-          submodules: recursive
-
-      - name: Checkout docs target branch
-        uses: actions/checkout@v3
-        with:
-          fetch-depth: 0
-          ref: ${{ steps.variables.outputs.target-branch }}
-          path: docs-target
-
       - uses: actions/setup-node@v3
         with:
           node-version: 16
@@ -82,21 +78,25 @@ jobs:
           cd doc
           hugo --minify --destination ../website --baseURL=${{ steps.variables.outputs.baseUrl }}
 
-      # TODO build the C/C++/C# docs
-
       - name: Copy & push the generated HTML
         run: |
+          # TODO build the C/C++/C# docs for master/staging
           set -x
-          cd docs-target
-          # delete anything but: 1) '.'; 2) '..'; 3) .git/
-          find ./ | grep -vE "^./$|^../$|^./.git" | xargs rm -rf
-          cp ../.asf.yaml .
-          cp -r ../website/* .
-          # TODO copy the C/C++/C# docs
+          sed -i -e "s|TARGET_BRANCH|${{ steps.variables.outputs.target-branch }}|" .asf.yaml
+          sed -i -e "s|SUBDIR|${{ steps.variables.outputs.version }}|" .asf.yaml
+          cp .asf.yaml website/
+          git checkout -B ${{ steps.variables.outputs.target-branch }}
+          # delete anything but: 1) '.'; 2) '..'; 3) .git/; 4) website/
+          find ./ | grep -vE "^./$|^../$|^./.git|^./website" | xargs rm -rf
+          mv website/* .
+          mv website/.asf.yaml .
+          ls -la website/
+          rmdir website
+          # TODO copy the C/C++/C# docs for master/staging
           if [ "$(git status --porcelain)" != "" ]; then
             git config user.name "github-actions[bot]"
             git config user.email "github-actions[bot]@users.noreply.github.com"
             git add --all
             git commit -m 'Publish built docs triggered by ${{ github.sha }}'
-            git push || git push --force
+            git push --set-upstream origin ${{ steps.variables.outputs.target-branch }} --force
           fi