|
| 1 | +# Copyright (c) 2021, 2023, Oracle and/or its affiliates. |
| 2 | +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. |
| 3 | +# |
| 4 | +# Description |
| 5 | +# Use Hugo to build static site and publish to gh-pages |
| 6 | +# |
| 7 | +name: "PublishLatestMinorGitHubPages" |
| 8 | + |
| 9 | +on: |
| 10 | + push: |
| 11 | + branches: |
| 12 | + - release/4.1 |
| 13 | + paths: |
| 14 | + - 'documentation/**' |
| 15 | + |
| 16 | +defaults: |
| 17 | + run: |
| 18 | + shell: bash |
| 19 | + |
| 20 | +jobs: |
| 21 | + publish: |
| 22 | + name: Publish |
| 23 | + runs-on: ubuntu-latest |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout branch |
| 27 | + uses: actions/checkout@v3 |
| 28 | + with: |
| 29 | + fetch-depth: 32 |
| 30 | + path: branch |
| 31 | + |
| 32 | + - name: Checkout gh-pages |
| 33 | + uses: actions/checkout@v3 |
| 34 | + with: |
| 35 | + ref: gh-pages |
| 36 | + path: gh-pages |
| 37 | + token: ${{ secrets.PUBLISH_SECRET }} |
| 38 | + |
| 39 | + - name: Build and publish site |
| 40 | + run: | |
| 41 | + curl -fL -o hugo.tar.gz "https://github.com/gohugoio/hugo/releases/download/v0.108.0/hugo_0.108.0_Linux-64bit.tar.gz" |
| 42 | + tar -xf hugo.tar.gz |
| 43 | + export PATH="$PWD:$PATH" |
| 44 | + mkdir $GITHUB_WORKSPACE/WORK |
| 45 | + |
| 46 | + cp -R $GITHUB_WORKSPACE/gh-pages/charts $GITHUB_WORKSPACE/WORK |
| 47 | + |
| 48 | + cd $GITHUB_WORKSPACE/branch/documentation |
| 49 | + echo "Documentation branch is $GITHUB_REF_NAME..." |
| 50 | + latest_tag=$(git ls-remote https://github.com/oracle/weblogic-kubernetes-operator.git --h --sort origin "refs/tags/v*" | cut -f2 | grep v4.1 | tail -1 | cut -c12-) |
| 51 | + echo "Latest tag is $latest_tag..." |
| 52 | + echo $latest_tag >| $GITHUB_WORKSPACE/branch/documentation/site/layouts/shortcodes/latestVersion.html |
| 53 | + echo "Building documentation for latest minor version..." |
| 54 | + hugo -s site -d "$GITHUB_WORKSPACE/WORK" -b https://oracle.github.io/weblogic-kubernetes-operator |
| 55 | + echo "Copying static files into place..." |
| 56 | + cp -R domains "$GITHUB_WORKSPACE/WORK" |
| 57 | + cd $GITHUB_WORKSPACE/gh-pages |
| 58 | + find . -maxdepth 1 -mindepth 1 -not -name '[0-9]*' -not -name '.git*' -exec rm -Rf {} \; |
| 59 | + cp -R $GITHUB_WORKSPACE/WORK/* . |
| 60 | + git config --global user.name "github-actions[bot]" |
| 61 | + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 62 | + git add --all |
| 63 | + git commit -m "Documentation update from publish GitHub Action" |
| 64 | + git push origin gh-pages |
0 commit comments