Skip to content

PublishGitHubPages #370

PublishGitHubPages

PublishGitHubPages #370

# Copyright (c) 2021, 2023, 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:
push:
branches:
- 'main'
paths:
- 'documentation/**'
schedule:
- cron: '15 3 * * 1'
defaults:
run:
shell: bash
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@v4
with:
ref: main
path: main
- name: Checkout gh-pages
uses: actions/checkout@v4
with:
ref: gh-pages
path: gh-pages
token: ${{ secrets.PUBLISH_SECRET }}
- name: Build and publish site
run: |
echo "Downloading Hugo for generating HTML documentation from Markdown"
curl -fL -o hugo.tar.gz "https://github.com/gohugoio/hugo/releases/download/v0.108.0/hugo_0.108.0_Linux-64bit.tar.gz"
tar -xf hugo.tar.gz
export PATH="$PWD:$PATH"
mkdir $GITHUB_WORKSPACE/WORK
echo "Building HTML documentation for main branch..."
cd $GITHUB_WORKSPACE/main/documentation
# Generate documentation into $GITHUB_WORKSPACE/WORK using Markdown source in the ./site folder
hugo -s site -d "$GITHUB_WORKSPACE/WORK" -b https://oracle.github.io/weblogic-image-tool
echo "Remove existing documentation files and replace them with newly generated files in branch gh-pages"
cd $GITHUB_WORKSPACE/gh-pages
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