Skip to content

Commit

Permalink
ci: fix posting nightly docs on flex
Browse files Browse the repository at this point in the history
Signed-off-by: moabu <[email protected]>
  • Loading branch information
moabu committed Jan 28, 2025
1 parent 61e1217 commit 8b24ef0
Showing 1 changed file with 39 additions and 18 deletions.
57 changes: 39 additions & 18 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,36 @@ on:
workflow_dispatch:
inputs:
version:
description: 'Version tag (e.g."v5.0.0-14")'
default: "v5.0.0-19"
description: 'Version tag (e.g."v5.1.6")'
default: "nightly"
required: false
concurrency:
group: run-once
cancel-in-progress: false
permissions:
contents: read

jobs:
build:
if: github.repository_owner == 'GluuFederation'
permissions:
contents: write # for Git to git push
if: github.repository == 'GluuFederation/flex'
name: Deploy docs
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
token: ${{ secrets.MOWORKFLOWTOKEN }}

- name: Set up Python 3.10
uses: actions/setup-python@v4
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: "3.10"
cache: pip
Expand All @@ -57,7 +65,7 @@ jobs:
- name: Checkout flex ${{ github.event.inputs.version }}
if: >-
github.event_name == 'workflow_dispatch'
uses: actions/checkout@v3
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: '${{ github.event.inputs.version }}'
fetch-depth: 0
Expand All @@ -77,7 +85,7 @@ jobs:
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v5
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0
with:
gpg_private_key: ${{ secrets.MOAUTO_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.MOAUTO_GPG_PRIVATE_KEY_PASSPHRASE }}
Expand All @@ -94,7 +102,10 @@ jobs:
- name: Generate docs
continue-on-error: true
if: >-
github.event_name != 'pull_request'
github.event_name == 'release' &&
github.event.action == 'published' &&
(!github.event.release.draft) &&
(startsWith(github.event.release.name, 'v') || github.event.release.name == 'nightly')
env:
VERSION: ${{ github.event.release.tag_name }}
run: |
Expand Down Expand Up @@ -133,8 +144,8 @@ jobs:
if: >-
github.event_name == 'release' &&
github.event.action == 'published' &&
startsWith(github.event.release.name, 'v') &&
!github.event.release.draft
(!github.event.release.draft) &&
(startsWith(github.event.release.name, 'v') || github.event.release.name == 'nightly')
env:
VERSION: ${{ github.event.release.tag_name }}
run: |
Expand All @@ -145,28 +156,30 @@ jobs:
# github.event_name != 'workflow_dispatch'
id: set_versions
run: |
GITHUB_EVENT_RELEASE_TAG_NAME="${{ github.event.release.tag_name }}"
TAGS=$(gh release list -L 1000 -R ${{ github.repository }} | grep -o '^\v.*'| grep -v Draft | cut -f 1 | sed '/-/!{s/$/_/}' | sort -V | sed 's/_$//')
LATEST=$(echo "${TAGS}" | tail -1)
STABLE=$(echo "${TAGS}" | grep -v -- "nightly" | tail -1)
if [[ "$GITHUB_EVENT_RELEASE_TAG_NAME" == 'nightly' ]]; then
LATEST='nightly'
fi
echo "Latest is $LATEST and Stable is $STABLE"
# remove below two lines after first release
#LATEST="head"
#STABLE="head"
mike alias -u head main
mike alias -u "${STABLE}" stable
mike set-default --push stable
echo ::set-output name=LATEST::${LATEST}
echo ::set-output name=STABLE::${STABLE}
echo "LATEST=${LATEST}" >> $GITHUB_OUTPUT
echo "STABLE=${STABLE}" >> $GITHUB_OUTPUT
# Ensures the current branch is gh-pages,
# Creates / updates the "stable" and "latest" plain text files with the corresponding versions
# Commits if the files were changed
# Finally pushes if there are unpushed commits
- name: Create version files
if: >-
github.event_name != 'pull_request'
env:
VERSION: ${{ github.event.release.tag_name }}
#if: >-
# github.event_name != 'workflow_dispatch'
run: |
LATEST=${{ steps.set_versions.outputs.LATEST }}
STABLE=${{ steps.set_versions.outputs.STABLE }}
Expand All @@ -183,8 +196,16 @@ jobs:
echo "Replacing release number markers with actual release number"
cd ${LATEST}
egrep -lRZ --exclude=CONTRIBUTING.md . | xargs -0 -l sed -i -e "s/replace-flex-version/${LATEST:1}/g"
egrep -lRZ --exclude=CONTRIBUTING.md . | xargs -0 -l sed -i -e "s/replace-jans-version/${LATEST:1}/g"
if [[ "${LATEST}" == "nightly" ]]; then
egrep -lRZ --exclude=CONTRIBUTING.md . | xargs -0 -l sed -i -e "s/replace-janssen-version-stable/0.0.0-nightly/g"
egrep -lRZ --exclude=CONTRIBUTING.md . | xargs -0 -l sed -i -e "s/replace-janssen-version/0.0.0-nightly/g"
egrep -lRZ --exclude=CONTRIBUTING.md . | xargs -0 -l sed -i -e "s/replace-flex-version-stable/0.0.0-nightly/g
egrep -lRZ --exclude=CONTRIBUTING.md . | xargs -0 -l sed -i -e "s/replace-flex-version/0.0.0-nightly/g"
egrep -lRZ --exclude=CONTRIBUTING.md . | xargs -0 -l sed -i -e "s/v0.0.0-nightly/nightly/g"
else
egrep -lRZ --exclude=CONTRIBUTING.md . | xargs -0 -l sed -i -e "s/replace-flex-version/${LATEST:1}/g
egrep -lRZ --exclude=CONTRIBUTING.md . | xargs -0 -l sed -i -e "s/replace-janssen-version/${LATEST:1}/g"
fi
git add . && git update-index --refresh
cd ..
Expand Down

0 comments on commit 8b24ef0

Please sign in to comment.