Skip to content

Commit 8b24ef0

Browse files
committed
ci: fix posting nightly docs on flex
Signed-off-by: moabu <47318409+moabu@users.noreply.github.com>
1 parent 61e1217 commit 8b24ef0

File tree

1 file changed

+39
-18
lines changed

1 file changed

+39
-18
lines changed

.github/workflows/build-docs.yml

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,36 @@ on:
2222
workflow_dispatch:
2323
inputs:
2424
version:
25-
description: 'Version tag (e.g."v5.0.0-14")'
26-
default: "v5.0.0-19"
25+
description: 'Version tag (e.g."v5.1.6")'
26+
default: "nightly"
2727
required: false
2828
concurrency:
2929
group: run-once
3030
cancel-in-progress: false
3131
permissions:
3232
contents: read
33+
3334
jobs:
3435
build:
35-
if: github.repository_owner == 'GluuFederation'
36+
permissions:
37+
contents: write # for Git to git push
38+
if: github.repository == 'GluuFederation/flex'
3639
name: Deploy docs
3740
runs-on: ubuntu-latest
3841
steps:
42+
- name: Harden Runner
43+
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
44+
with:
45+
egress-policy: audit
46+
3947
- name: Checkout
40-
uses: actions/checkout@v3
48+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
4149
with:
4250
fetch-depth: 0
4351
token: ${{ secrets.MOWORKFLOWTOKEN }}
4452

4553
- name: Set up Python 3.10
46-
uses: actions/setup-python@v4
54+
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
4755
with:
4856
python-version: "3.10"
4957
cache: pip
@@ -57,7 +65,7 @@ jobs:
5765
- name: Checkout flex ${{ github.event.inputs.version }}
5866
if: >-
5967
github.event_name == 'workflow_dispatch'
60-
uses: actions/checkout@v3
68+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
6169
with:
6270
ref: '${{ github.event.inputs.version }}'
6371
fetch-depth: 0
@@ -77,7 +85,7 @@ jobs:
7785
7886
- name: Import GPG key
7987
id: import_gpg
80-
uses: crazy-max/ghaction-import-gpg@v5
88+
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0
8189
with:
8290
gpg_private_key: ${{ secrets.MOAUTO_GPG_PRIVATE_KEY }}
8391
passphrase: ${{ secrets.MOAUTO_GPG_PRIVATE_KEY_PASSPHRASE }}
@@ -94,7 +102,10 @@ jobs:
94102
- name: Generate docs
95103
continue-on-error: true
96104
if: >-
97-
github.event_name != 'pull_request'
105+
github.event_name == 'release' &&
106+
github.event.action == 'published' &&
107+
(!github.event.release.draft) &&
108+
(startsWith(github.event.release.name, 'v') || github.event.release.name == 'nightly')
98109
env:
99110
VERSION: ${{ github.event.release.tag_name }}
100111
run: |
@@ -133,8 +144,8 @@ jobs:
133144
if: >-
134145
github.event_name == 'release' &&
135146
github.event.action == 'published' &&
136-
startsWith(github.event.release.name, 'v') &&
137-
!github.event.release.draft
147+
(!github.event.release.draft) &&
148+
(startsWith(github.event.release.name, 'v') || github.event.release.name == 'nightly')
138149
env:
139150
VERSION: ${{ github.event.release.tag_name }}
140151
run: |
@@ -145,28 +156,30 @@ jobs:
145156
# github.event_name != 'workflow_dispatch'
146157
id: set_versions
147158
run: |
159+
GITHUB_EVENT_RELEASE_TAG_NAME="${{ github.event.release.tag_name }}"
148160
TAGS=$(gh release list -L 1000 -R ${{ github.repository }} | grep -o '^\v.*'| grep -v Draft | cut -f 1 | sed '/-/!{s/$/_/}' | sort -V | sed 's/_$//')
149161
LATEST=$(echo "${TAGS}" | tail -1)
150162
STABLE=$(echo "${TAGS}" | grep -v -- "nightly" | tail -1)
163+
if [[ "$GITHUB_EVENT_RELEASE_TAG_NAME" == 'nightly' ]]; then
164+
LATEST='nightly'
165+
fi
151166
echo "Latest is $LATEST and Stable is $STABLE"
152167
# remove below two lines after first release
153168
#LATEST="head"
154169
#STABLE="head"
155170
mike alias -u head main
156171
mike alias -u "${STABLE}" stable
157172
mike set-default --push stable
158-
echo ::set-output name=LATEST::${LATEST}
159-
echo ::set-output name=STABLE::${STABLE}
173+
echo "LATEST=${LATEST}" >> $GITHUB_OUTPUT
174+
echo "STABLE=${STABLE}" >> $GITHUB_OUTPUT
160175
161176
# Ensures the current branch is gh-pages,
162177
# Creates / updates the "stable" and "latest" plain text files with the corresponding versions
163178
# Commits if the files were changed
164179
# Finally pushes if there are unpushed commits
165180
- name: Create version files
166-
if: >-
167-
github.event_name != 'pull_request'
168-
env:
169-
VERSION: ${{ github.event.release.tag_name }}
181+
#if: >-
182+
# github.event_name != 'workflow_dispatch'
170183
run: |
171184
LATEST=${{ steps.set_versions.outputs.LATEST }}
172185
STABLE=${{ steps.set_versions.outputs.STABLE }}
@@ -183,8 +196,16 @@ jobs:
183196
184197
echo "Replacing release number markers with actual release number"
185198
cd ${LATEST}
186-
egrep -lRZ --exclude=CONTRIBUTING.md . | xargs -0 -l sed -i -e "s/replace-flex-version/${LATEST:1}/g"
187-
egrep -lRZ --exclude=CONTRIBUTING.md . | xargs -0 -l sed -i -e "s/replace-jans-version/${LATEST:1}/g"
199+
if [[ "${LATEST}" == "nightly" ]]; then
200+
egrep -lRZ --exclude=CONTRIBUTING.md . | xargs -0 -l sed -i -e "s/replace-janssen-version-stable/0.0.0-nightly/g"
201+
egrep -lRZ --exclude=CONTRIBUTING.md . | xargs -0 -l sed -i -e "s/replace-janssen-version/0.0.0-nightly/g"
202+
egrep -lRZ --exclude=CONTRIBUTING.md . | xargs -0 -l sed -i -e "s/replace-flex-version-stable/0.0.0-nightly/g
203+
egrep -lRZ --exclude=CONTRIBUTING.md . | xargs -0 -l sed -i -e "s/replace-flex-version/0.0.0-nightly/g"
204+
egrep -lRZ --exclude=CONTRIBUTING.md . | xargs -0 -l sed -i -e "s/v0.0.0-nightly/nightly/g"
205+
else
206+
egrep -lRZ --exclude=CONTRIBUTING.md . | xargs -0 -l sed -i -e "s/replace-flex-version/${LATEST:1}/g
207+
egrep -lRZ --exclude=CONTRIBUTING.md . | xargs -0 -l sed -i -e "s/replace-janssen-version/${LATEST:1}/g"
208+
fi
188209
git add . && git update-index --refresh
189210
cd ..
190211

0 commit comments

Comments
 (0)