1010jobs :
1111 build :
1212 name : Build
13- runs-on : ubuntu-20.04
13+ runs-on : ubuntu-latest
1414 continue-on-error : false
1515
1616 defaults :
@@ -26,81 +26,81 @@ jobs:
2626 deploy_version : ${{ steps.version.outputs.built_docs_version }}
2727
2828 steps :
29- - uses : actions/checkout@v4
30- with :
31- fetch-depth : 0
32- submodules : ' recursive'
33-
34- - name : Check version tag for deployment
35- id : version
36- shell : bash -l {0}
37- run : |
38- if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
39- # It may be a PR against a non-master branch, but that doesn't matter here.
40- version="master"
41- elif [[ "$GITHUB_EVENT_NAME" == "push" && "${{ github.ref }}" = refs/heads/* ]]; then
42- # If this is a push to a branch, then use that branch name.
43- # `basename refs/heads/a` -> "a"
44- version="$(basename "${{ github.ref }}")"
45- else
46- # For refs/tags and anything else, use the version from git.
47- version="$(git describe --tags)"
48- fi
49- (
50- echo "Package version: $(git describe --tags)"
51- echo "Documentation version name: ${version}"
52- ) | tee "$GITHUB_STEP_SUMMARY"
53-
54- echo "built_docs_version=${version}" >> $GITHUB_OUTPUT
55-
56- - name : Check environment variables for issues
57- run : |
58- if [ -z "${{ steps.version.outputs.built_docs_version }}" ]; then
59- echo "Built docs version unset? See previous step"
60- exit 1
61- fi
62-
63- - name : Prepare for log files
64- run : |
65- mkdir $HOME/logs
66-
67- - uses : actions/setup-python@v5
68- with :
69- python-version : ' 3.10'
70-
71- - name : Upgrade pip
72- run : |
73- pip install --upgrade pip
74-
75- - name : Install blark
76- run : |
77- pip install .[doc]
78-
79- - name : List all pip packages
80- run : |
81- pip list
82-
83- - name : Build documentation
84- run : |
85- cd docs
86- make html 2>&1 | tee $HOME/logs/docs-build.txt
87-
88- - name : Upload documentation as artifact
89- uses : actions/upload-artifact@v3
90- with :
91- name : Documentation
92- path : " docs/build/html"
93-
94- - name : Upload log file artifacts
95- if : ${{ always() }}
96- uses : actions/upload-artifact@v3
97- with :
98- name : Documentation - logs
99- path : " ~/logs"
29+ - uses : actions/checkout@v4
30+ with :
31+ fetch-depth : 0
32+ submodules : " recursive"
33+
34+ - name : Check version tag for deployment
35+ id : version
36+ shell : bash -l {0}
37+ run : |
38+ if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
39+ # It may be a PR against a non-master branch, but that doesn't matter here.
40+ version="master"
41+ elif [[ "$GITHUB_EVENT_NAME" == "push" && "${{ github.ref }}" = refs/heads/* ]]; then
42+ # If this is a push to a branch, then use that branch name.
43+ # `basename refs/heads/a` -> "a"
44+ version="$(basename "${{ github.ref }}")"
45+ else
46+ # For refs/tags and anything else, use the version from git.
47+ version="$(git describe --tags)"
48+ fi
49+ (
50+ echo "Package version: $(git describe --tags)"
51+ echo "Documentation version name: ${version}"
52+ ) | tee "$GITHUB_STEP_SUMMARY"
53+
54+ echo "built_docs_version=${version}" >> $GITHUB_OUTPUT
55+
56+ - name : Check environment variables for issues
57+ run : |
58+ if [ -z "${{ steps.version.outputs.built_docs_version }}" ]; then
59+ echo "Built docs version unset? See previous step"
60+ exit 1
61+ fi
62+
63+ - name : Prepare for log files
64+ run : |
65+ mkdir $HOME/logs
66+
67+ - uses : actions/setup-python@v5
68+ with :
69+ python-version : " 3.10"
70+
71+ - name : Upgrade pip
72+ run : |
73+ pip install --upgrade pip
74+
75+ - name : Install blark
76+ run : |
77+ pip install .[doc]
78+
79+ - name : List all pip packages
80+ run : |
81+ pip list
82+
83+ - name : Build documentation
84+ run : |
85+ cd docs
86+ make html 2>&1 | tee $HOME/logs/docs-build.txt
87+
88+ - name : Upload documentation as artifact
89+ uses : actions/upload-artifact@v4
90+ with :
91+ name : Documentation
92+ path : " docs/build/html"
93+
94+ - name : Upload log file artifacts
95+ if : ${{ always() }}
96+ uses : actions/upload-artifact@v4
97+ with :
98+ name : Documentation - logs
99+ path : " ~/logs"
100100
101101 deploy :
102102 name : Deploy
103- runs-on : ubuntu-20.04
103+ runs-on : ubuntu-latest
104104 needs : build
105105 if : ${{ github.repository_owner == 'klauer' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')) }}
106106
@@ -127,88 +127,88 @@ jobs:
127127 # url: ${{ steps.build-and-deploy.outputs.page_url }}
128128
129129 steps :
130- - uses : actions/setup-python@v4
131- with :
132- python-version : ' 3.10'
133-
134- - name : Installing documentation upload requirements
135- run : |
136- pip install --upgrade pip
137- pip install docs-versions-menu
138-
139- - name : Download documentation artifact
140- uses : actions/download-artifact@v3
141- with :
142- name : Documentation
143-
144- - name : Configure git for docs deployment
145- run : |
146- git config --global user.name github-actions
147- git config --global user.email github-actions@github.com
148- git config --global init.defaultBranch gh-pages
149-
150- - name : List cached documentation
151- run : |
152- ls -lR
153-
154- - name : Update documentation with docs-versions-menu
155- run : |
156- # Adapted from my pcds-ci-helpers work:
157- # https://github.com/pcdshub/pcds-ci-helpers/blob/master/.github/workflows/python-docs.yml
158- set -x
159- git clone --branch gh-pages https://github.com/${{ github.repository }} "$HOME/gh-pages" || (
160- mkdir "$HOME/gh-pages"
130+ - uses : actions/setup-python@v4
131+ with :
132+ python-version : " 3.10"
133+
134+ - name : Installing documentation upload requirements
135+ run : |
136+ pip install --upgrade pip
137+ pip install docs-versions-menu
138+
139+ - name : Download documentation artifact
140+ uses : actions/download-artifact@v3
141+ with :
142+ name : Documentation
143+
144+ - name : Configure git for docs deployment
145+ run : |
146+ git config --global user.name github-actions
147+ git config --global user.email github-actions@github.com
148+ git config --global init.defaultBranch gh-pages
149+
150+ - name : List cached documentation
151+ run : |
152+ ls -lR
153+
154+ - name : Update documentation with docs-versions-menu
155+ run : |
156+ # Adapted from my pcds-ci-helpers work:
157+ # https://github.com/pcdshub/pcds-ci-helpers/blob/master/.github/workflows/python-docs.yml
158+ set -x
159+ git clone --branch gh-pages https://github.com/${{ github.repository }} "$HOME/gh-pages" || (
160+ mkdir "$HOME/gh-pages"
161+ cd "$HOME/gh-pages"
162+ git init
163+ )
164+ rsync -av --delete ./ "$HOME/gh-pages/${{ needs.build.outputs.deploy_version }}/"
165+
166+ # Run docs-versions-menu
161167 cd "$HOME/gh-pages"
162- git init
163- )
164- rsync -av --delete ./ "$HOME/gh-pages/${{ needs.build.outputs.deploy_version }}/"
165-
166- # Run docs-versions-menu
167- cd "$HOME/gh-pages"
168- docs-versions-menu
169-
170- - name : Commit updated documentation to gh-pages
171- run : |
172- cd "$HOME/gh-pages"
173-
174- git add --all --verbose
175- git status
176-
177- if ! git rev-parse HEAD &>/dev/null ; then
178- git commit --verbose \
179- -m "Initial commit of documentation" \
180- -m "Deployed from commit ${GITHUB_SHA} (${GITHUB_REF})"
181- else
182- commit_message_file="$HOME/documentation_commit_message.txt"
183- echo "The commit message will be:"
184- echo "---------------------------"
185- git log --format=%B -n 1 | tee "${commit_message_file}"
186- echo "---------------------------"
187- last_log_line=$(cat "${commit_message_file}" | grep -v '^$' | tail -n1)
188- last_author=$(git log --format=%an -n 1)
189- echo "Last log line: ${last_log_line}"
190- echo "Last author: ${last_author}"
191- echo "Current ref: ${{ github.ref }}"
192- if [[ "$last_author" == "github-actions"* && "$last_log_line" == *"${{ github.ref }}"* ]]; then
193- # Amend if the previous commit was done by Actions and was based on the same branch/tag name
194- echo "Amending previous commit"
195- echo "Deployed from commit ${GITHUB_SHA} (${GITHUB_REF})" >> "${commit_message_file}"
196- git commit --verbose --amend --file="${commit_message_file}"
197- else
198- echo "Making new commit"
168+ docs-versions-menu
169+
170+ - name : Commit updated documentation to gh-pages
171+ run : |
172+ cd "$HOME/gh-pages"
173+
174+ git add --all --verbose
175+ git status
176+
177+ if ! git rev-parse HEAD &>/dev/null ; then
199178 git commit --verbose \
200- -m "Auto-update from Github Actions Workflow" \
201- -m "Deployed from commit ${GITHUB_SHA} (${GITHUB_REF})" ||
202- echo "Documentation unchanged"
179+ -m "Initial commit of documentation" \
180+ -m "Deployed from commit ${GITHUB_SHA} (${GITHUB_REF})"
181+ else
182+ commit_message_file="$HOME/documentation_commit_message.txt"
183+ echo "The commit message will be:"
184+ echo "---------------------------"
185+ git log --format=%B -n 1 | tee "${commit_message_file}"
186+ echo "---------------------------"
187+ last_log_line=$(cat "${commit_message_file}" | grep -v '^$' | tail -n1)
188+ last_author=$(git log --format=%an -n 1)
189+ echo "Last log line: ${last_log_line}"
190+ echo "Last author: ${last_author}"
191+ echo "Current ref: ${{ github.ref }}"
192+ if [[ "$last_author" == "github-actions"* && "$last_log_line" == *"${{ github.ref }}"* ]]; then
193+ # Amend if the previous commit was done by Actions and was based on the same branch/tag name
194+ echo "Amending previous commit"
195+ echo "Deployed from commit ${GITHUB_SHA} (${GITHUB_REF})" >> "${commit_message_file}"
196+ git commit --verbose --amend --file="${commit_message_file}"
197+ else
198+ echo "Making new commit"
199+ git commit --verbose \
200+ -m "Auto-update from Github Actions Workflow" \
201+ -m "Deployed from commit ${GITHUB_SHA} (${GITHUB_REF})" ||
202+ echo "Documentation unchanged"
203+ fi
203204 fi
204- fi
205- git log -n 2 --stat
206-
207- - name : Pushing documentation
208- run : |
209- cd "$HOME/gh-pages"
210- # --force-with-lease=gh-pages
211- git push --verbose \
212- --force \
213- "https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" \
214- gh-pages
205+ git log -n 2 --stat
206+
207+ - name : Pushing documentation
208+ run : |
209+ cd "$HOME/gh-pages"
210+ # --force-with-lease=gh-pages
211+ git push --verbose \
212+ --force \
213+ "https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" \
214+ gh-pages
0 commit comments