Skip to content
Browse files
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.
  • Loading branch information
tobous committed Jan 21, 2021
1 parent fc7dbde commit 6bf63dda9f0e6a2120b0380a553ebdea52f7f5b7
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 40 deletions.
@@ -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.
profile: ~
whoami: staging
subdir: content/jdo

whoami: master
subdir: content/jdo

description: "Apache JDO project"
@@ -0,0 +1,6 @@
# Publishing profile for Apache JDO website
# This file is only used on the site publishing branch
whoami: publish
subdir: jdo
@@ -5,18 +5,18 @@ name: Build & Deploy Site
# 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
- '**'
- '!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
- 'src/main/asciidoc/**'
- 'src/main/template/**'
- '.asf.yaml.publish'

@@ -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 $author_name
git config $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)
# nothing staged
echo "Nothing to commit"
exit 0
echo "Setting up author data"
git config "${{ }}"
git config "${{ }}"
echo "Commiting changes"
echo "Creating orphan branch"
git checkout --orphan $branch_name
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 "Committing changes"
git commit -m "Auto-deploy site for commit ${{ steps.short-sha.outputs.short_sha }}"
echo "Pushing changes"
git push
echo "Pushing site branch"
git push -f origin $branch_name
shell: 'bash'

This file was deleted.

0 comments on commit 6bf63dd

Please sign in to comment.