You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-dev@db.apache.org by to...@apache.org on 2021/01/21 19:51:05 UTC

[db-jdo-site] branch master updated: Move site build artifacts to separate site branch

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

tobous pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/db-jdo-site.git


The following commit(s) were added to refs/heads/master by this push:
     new 6bf63dd  Move site build artifacts to separate site branch
6bf63dd is described below

commit 6bf63dda9f0e6a2120b0380a553ebdea52f7f5b7
Author: Tobias Bouschen <to...@googlemail.com>
AuthorDate: Sun Jan 3 17:32:27 2021 +0100

    Move site build artifacts to separate site branch
    
    Adjusts the deploy action to create a new orphan branch 'publish'
    containing only the site build artifacts and site configuration files in
    the root directory. This branch is then force-pushed to the repo,
    replacing the previous site build.
    
    This approach avoids having to include the site artifacts in the master
    branch, reducing the repository size and avoiding including "deploy"
    commits in the main history.
    
    Creates a new '.asf.yaml.publish' that will be used to publish the site
    branch. Moves the publishing configuration from the main configuration
    file to the publishing configuration file. Changes the branch id to
    'publish'. Drops the 'staging' configuration as it reportedly does not
    function correctly. Furthermore, the current content of the 'staging'
    branch is no longer deployable with the new setup as it still uses the
    old site deploy scheme.
    
    Removes the '.htaccess' configuration as the redirection is no longer
    necessary now that the resources are hosted in the root directory.
---
 .asf.yaml                         | 12 --------
 .asf.yaml.publish                 |  6 ++++
 .github/workflows/deploy-site.yml | 65 ++++++++++++++++++++++++---------------
 .htaccess                         |  3 --
 4 files changed, 46 insertions(+), 40 deletions(-)

diff --git a/.asf.yaml b/.asf.yaml
index bcdb816..38b2fc1 100644
--- a/.asf.yaml
+++ b/.asf.yaml
@@ -1,15 +1,3 @@
-# Staging and publishing profile for Apache JDO
-# NOTE: This does currently not work, presumably because JDO is a sub project and there is 
-#       no staging area for subprojects or for the parent 'db' project.
-staging:
-  profile: ~
-  whoami:  staging
-  subdir: content/jdo
- 
-publish:
-  whoami:  master
-  subdir:  content/jdo
-
 github:
   description: "Apache JDO project"
   homepage: https://db.apache.org/jdo
diff --git a/.asf.yaml.publish b/.asf.yaml.publish
new file mode 100644
index 0000000..b08720c
--- /dev/null
+++ b/.asf.yaml.publish
@@ -0,0 +1,6 @@
+# Publishing profile for Apache JDO website
+#
+# This file is only used on the site publishing branch
+publish:
+  whoami:  publish
+  subdir:  jdo
diff --git a/.github/workflows/deploy-site.yml b/.github/workflows/deploy-site.yml
index b8e37f6..4a1056a 100644
--- a/.github/workflows/deploy-site.yml
+++ b/.github/workflows/deploy-site.yml
@@ -5,18 +5,18 @@ name: Build & Deploy Site
 on:
   push:
     # Ignore pushes on all branches by default
-    # branches that should trigger a build must be explicitly excluded from the ignore using '!BRANCH_NAME'
+    # Branches that should trigger a build must be explicitly excluded from the ignore using '!BRANCH_NAME'
+    #
+    # Excluding the branch that is pushed by this action will lead to an infinite loop
     branches-ignore:
       - '**'
       - '!master'
 
     # Only build if a file in one of these paths has been changed
-    #
-    # This list must not contains directories which are modified and commited as part of this action
-    # Such a setup would lead to an infinite loop where the push as part of the action triggers a new run of the action
     paths:
       - 'src/main/asciidoc/**'
       - 'src/main/template/**'
+      - '.asf.yaml.publish'
 
 jobs:
   build:
@@ -29,7 +29,7 @@ jobs:
           fetch-depth: 1
 
       - name: Build Site
-        run: mvn clean install
+        run: mvn clean compile
 
       # Determines the short sha of the commit that triggered the build
       - name: Determine Short SHA
@@ -40,34 +40,49 @@ jobs:
           echo "::set-output name=short_sha::$short_sha"
         shell: 'bash'
 
-      # Determine the author data of the HEAD commit which will be used for the deploy commit
-      - name: Determine HEAD Author Data
+      # Determines the author data of the HEAD commit
+      # Sets up the author data to be used for the site deploy commit
+      - name: Determine HEAD Commit Author Data
         if: success()
         id: author-data
         run: |
+          echo "Reading author data"
           author_name=$(git log -1 --format='%aN' HEAD)
-          echo "::set-output name=author_name::$author_name"
           author_email=$(git log -1 --format='%aE' HEAD)
-          echo "::set-output name=author_email::$author_email"
+
+          echo "Setting up author data to use for deploy commit"
+          git config user.name $author_name
+          git config user.email $author_email
         shell: 'bash'
 
-      # Commits any changes to the 'docs/' directory using the credentials of the current HEAD commit; does nothing if there is nothing to commit
-      - name: Commit Result
+      # Publishes the site build results to a separate orphan branch
+      #
+      # Creates and checks out a new orphan branch
+      # Creates a single commit containing only the site build artifacts and site configuration files located in the root directory
+      # The commit is created with the author data set up in the previous step
+      # Force-pushes the created branch, overwriting the previously published site build
+      - name: Publish site branch
         if: success()
         run: |
-          echo "Adding changes"
-          git add 'docs/'
-          if $(git diff -s --cached --exit-code)
-            then
-              # nothing staged
-              echo "Nothing to commit"
-              exit 0
-          fi
-          echo "Setting up author data"
-          git config user.name "${{ steps.author-data.outputs.author_name }}"
-          git config user.email "${{ steps.author-data.outputs.author_email }}"
-          echo "Commiting changes"
+          branch_name="publish"
+
+          echo "Creating orphan branch"
+          git checkout --orphan $branch_name
+          echo
+
+          echo "Dropping content other than site data"
+          git reset
+          rm .gitignore
+          git add .asf.yaml.publish target/site
+          git clean -df
+          git mv target/site/* ./
+          git mv .asf.yaml.publish .asf.yaml
+          echo
+
+          echo "Committing changes"
           git commit -m "Auto-deploy site for commit ${{ steps.short-sha.outputs.short_sha }}"
-          echo "Pushing changes"
-          git push
+          echo
+
+          echo "Pushing site branch"
+          git push -f origin $branch_name
         shell: 'bash'
diff --git a/.htaccess b/.htaccess
deleted file mode 100644
index a6561f7..0000000
--- a/.htaccess
+++ /dev/null
@@ -1,3 +0,0 @@
-RewriteEngine On
-RewriteBase /jdo/
-RewriteRule ^(?!docs/)(.*)$ docs/$1