Skip to content

Update hotfixes-2-17.md #217

Update hotfixes-2-17.md

Update hotfixes-2-17.md #217

name: Automated-Publish-Docs
on:
push:
branches:
- v*.*
paths-ignore:
- 'github/**'
jobs:
env:
runs-on: ubuntu-latest
outputs:
CURRENT_BRANCH: ${{ steps.calculate-env.outputs.current_branch }}
NEWEST_VERSION: ${{ steps.calculate-env.outputs.newest_version }}
ALIAS: ${{ steps.calculate-env.outputs.alias }}
TITLE: ${{ steps.calculate-env.outputs.title }}
SLACK_CHANNEL: "docs-review"
COMMIT_URL: ${{ steps.calculate-env.outputs.commit_url }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get all v*.* branches
id: calculate-env
run: |
BRANCHES=$(git branch -r | grep -E '^ *origin/v[0-9]{1,2}\.[0-9]{1,2}$' | sort -Vu | sed 's/origin\///g' | sed 's/ //g')
NEWEST_VERSION=$(printf '%s\n' "${BRANCHES[@]}" | sort -V | tail -n 1)
CURRENT_BRANCH=${GITHUB_REF#refs/heads/}
ALIAS=$CURRENT_BRANCH-alias
TITLE=$(echo $CURRENT_BRANCH | cut -b 2-)
echo current_branch=$CURRENT_BRANCH >> $GITHUB_OUTPUT
echo newest_version=$NEWEST_VERSION >> $GITHUB_OUTPUT
echo alias=$ALIAS >> $GITHUB_OUTPUT
echo title=$TITLE >> $GITHUB_OUTPUT
echo "commit_url=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/commit/$GITHUB_SHA" >> $GITHUB_OUTPUT
if [[ "$CURRENT_BRANCH" == "$NEWEST_VERSION" ]]; then
echo "Deploying $NEWEST_VERSION as latest..."
else
echo "Deploying $CURRENT_BRANCH which is not the latest version ( => $NEWEST_VERSION )..."
fi
install-dependencies-and-deploy:
name: Install Dependencies and Deploy
needs: [env]
runs-on: ubuntu-latest
steps:
- name: checkout latest
uses: actions/checkout@v4
with:
ref: ${{ needs.env.outputs.CURRENT_BRANCH }}
fetch-depth: 0
- name: setup python
uses: actions/setup-python@v5
with:
python-version: '3.9'
cache: 'pip' # caching pip dependencies
- name: install dependencies
run: |
pip3 install -r requirements.txt
- name: Configure Git User
run: |
git config user.name "circleci-runai"
git config user.email "[email protected]"
- name: deploy mkdocs
run: |
if [[ "${{ needs.env.outputs.CURRENT_BRANCH }}" == "${{ needs.env.outputs.NEWEST_VERSION }}" ]]; then
echo "Deploying ${{ needs.env.outputs.NEWEST_VERSION }} as latest..."
mike list
git fetch origin gh-pages --depth=1
mike deploy ${{ needs.env.outputs.CURRENT_BRANCH }} ${{ needs.env.outputs.ALIAS }} latest --title=${{ needs.env.outputs.TITLE }} --push --update-aliases
mike set-default latest --push
mike list
else
echo "Deploying ${{ needs.env.outputs.CURRENT_BRANCH }} which is not the latest version ( => ${{ needs.env.outputs.NEWEST_VERSION }} )..."
mike list
git fetch origin gh-pages --depth=1
mike deploy ${{ needs.env.outputs.CURRENT_BRANCH }} ${{ needs.env.outputs.ALIAS }} --title=${{ needs.env.outputs.TITLE }} --push
mike list
fi
slack-notification:
name: Slack Notification
needs: [env, install-dependencies-and-deploy]
if: always()
runs-on: ubuntu-latest
steps:
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_COLOR: ${{ contains(needs.*.result, 'failure') && 'failure' || 'success' }}
SLACK_TITLE: "RunAI-Docs: Version ${{ needs.env.outputs.CURRENT_BRANCH }} Deployment ${{ contains(needs.*.result, 'failure') && 'failed' || 'completed successfully' }}"
SLACK_MESSAGE_ON_SUCCESS: "Docs were updated successfully for version ${{ needs.env.outputs.TITLE }} ==> Commit Message: '${{ github.event.head_commit.message }}' ==> Commit URL: ${{ needs.env.outputs.COMMIT_URL }}"
SLACK_MESSAGE_ON_FAILURE: "Docs update FAILED for version ${{ needs.env.outputs.TITLE }} ==> Commit Message: '${{ github.event.head_commit.message }}' ==> Commit URL: ${{ needs.env.outputs.COMMIT_URL }}"
MSG_MINIMAL: true
SLACK_FOOTER: ""