Skip to content

PublishGitHubPages #559

PublishGitHubPages

PublishGitHubPages #559

# Copyright (c) 2021, 2024, Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
#
# Description
# Use Hugo to build static site and publish to gh-pages
#
name: "PublishGitHubPages"
on:
schedule:
- cron: '15 3 * * *'
defaults:
run:
shell: bash
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
fetch-depth: 32
ref: release/4.2
path: branch-4.2
- name: Checkout gh-pages
uses: actions/checkout@v4
with:
ref: gh-pages
path: gh-pages
token: ${{ secrets.GITHUB_TOKEN }}
- name: Build and publish site
run: |
curl -fL -o hugo.tar.gz "https://github.com/gohugoio/hugo/releases/download/v0.133.0/hugo_0.133.0_Linux-64bit.tar.gz"
tar -xf hugo.tar.gz
export PATH="$PWD:$PATH"
mkdir $GITHUB_WORKSPACE/WORK
cp -R $GITHUB_WORKSPACE/gh-pages/charts $GITHUB_WORKSPACE/WORK
cd $GITHUB_WORKSPACE/branch-4.2/documentation
echo "Building documentation for 4.2 minor version..."
latest_42_tag=$(git ls-remote https://github.com/oracle/weblogic-kubernetes-operator.git --h --sort origin "refs/tags/v*" | cut -f2 | grep v4.2 | cut -c12- | sort --version-sort | tail -1)
echo "Latest tag is $latest_42_tag..."
echo $latest_42_tag >| $GITHUB_WORKSPACE/branch-4.2/documentation/site/layouts/shortcodes/latestVersion.html
cat $GITHUB_WORKSPACE/branch-4.2/documentation/site/layouts/shortcodes/latestVersion.html
hugo -s site -d "$GITHUB_WORKSPACE/WORK" -b https://oracle.github.io/weblogic-kubernetes-operator
echo "Copying static files into place..."
cp -R domains "$GITHUB_WORKSPACE/WORK"
cd $GITHUB_WORKSPACE/gh-pages
find . -maxdepth 1 -mindepth 1 -not -name '[0-9]*' -not -name '.git*' -exec rm -Rf {} \;
cp -R $GITHUB_WORKSPACE/WORK/* .
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add --all
git commit -m "Documentation update from publish GitHub Action"
git push origin gh-pages