-
Notifications
You must be signed in to change notification settings - Fork 212
89 lines (75 loc) · 3.37 KB
/
publish-gh-pages.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# 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:
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.1
path: branch-4.1
- name: Checkout branch
uses: actions/checkout@v4
with:
fetch-depth: 32
ref: release/4.0
path: branch-4.0
- name: Checkout branch
uses: actions/checkout@v4
with:
fetch-depth: 32
ref: release/3.4
path: branch-3.4
- 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: |
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
cp -R $GITHUB_WORKSPACE/gh-pages/charts $GITHUB_WORKSPACE/WORK
cd $GITHUB_WORKSPACE/branch-4.1/documentation
echo "Building documentation for 4.1 minor version..."
latest_41_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-)
echo "Latest tag is $latest_41_tag..."
echo $latest_41_tag >| $GITHUB_WORKSPACE/branch-4.1/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/branch-4.0/documentation
echo "Building documentation for 4.0 minor version..."
latest_40_tag=$(git ls-remote https://github.com/oracle/weblogic-kubernetes-operator.git --h --sort origin "refs/tags/v*" | cut -f2 | grep v4.0 | tail -1 | cut -c12-)
echo "Latest tag is $latest_40_tag..."
echo $latest_40_tag >| $GITHUB_WORKSPACE/branch-4.0/documentation/site/layouts/shortcodes/latestVersion.html
hugo -s site -d "$GITHUB_WORKSPACE/WORK/4.0" -b https://oracle.github.io/weblogic-kubernetes-operator/4.0
cd $GITHUB_WORKSPACE/branch-3.4/documentation
echo "Building documentation for 3.4 minor version..."
hugo -s site -d "$GITHUB_WORKSPACE/WORK/3.4" -b https://oracle.github.io/weblogic-kubernetes-operator/3.4
cd $GITHUB_WORKSPACE/gh-pages
find . -maxdepth 1 -mindepth 1 -not -name '[0-9]*' -not -name '.git*' -exec rm -Rf {} \;
rm -Rf 3.4 4.0
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