1
+ name : Automated-Publish-Docs
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - v*.*
7
+ paths-ignore :
8
+ - ' github/**'
9
+
10
+ jobs :
11
+ env :
12
+ runs-on : ubuntu-latest
13
+ outputs :
14
+ CURRENT_BRANCH : ${{ steps.calculate-env.outputs.current_branch }}
15
+ NEWEST_VERSION : ${{ steps.calculate-env.outputs.newest_version }}
16
+ ALIAS : ${{ steps.calculate-env.outputs.alias }}
17
+ TITLE : ${{ steps.calculate-env.outputs.title }}
18
+ SLACK_CHANNEL : " docs-review"
19
+ steps :
20
+ - name : Checkout code
21
+ uses : actions/checkout@v4
22
+
23
+ - name : Get all v*.* branches
24
+ id : calculate-env
25
+ run : |
26
+ BRANCHES=$(git branch --list --all | grep -v master | grep 'origin/v*.*' | sed -n -E 's:.*/(v[0-9]+\.[0-9]+).*:\1:p' | sort -Vu)
27
+ NEWEST_VERSION=$(printf '%s\n' "${BRANCHES[@]}" | sort -V | tail -n 1)
28
+ CURRENT_BRANCH=${GITHUB_REF#refs/heads/}
29
+ ALIAS=$CURRENT_BRANCH-alias
30
+ TITLE=$(echo $CURRENT_BRANCH | cut -b 2-)
31
+ echo current_branch=$CURRENT_BRANCH >> $GITHUB_OUTPUT
32
+ echo newest_version=$NEWEST_VERSION >> $GITHUB_OUTPUT
33
+ echo alias=$ALIAS >> $GITHUB_OUTPUT
34
+ echo title=$TITLE >> $GITHUB_OUTPUT
35
+
36
+ if [[ "$CURRENT_BRANCH" == "$NEWEST_VERSION" ]]; then
37
+ echo "Deploying $NEWEST_VERSION as latest..."
38
+ else
39
+ echo "Deploying $CURRENT_BRANCH which is not the latest version ( => $NEWEST_VERSION )..."
40
+ fi
41
+
42
+ install-dependencies-and-deploy :
43
+ name : Install Dependencies and Deploy
44
+ needs : [env]
45
+ runs-on : ubuntu-latest
46
+ steps :
47
+ - name : checkout latest
48
+ uses : actions/checkout@v4
49
+ with :
50
+ ref : ${{ needs.env.outputs.CURRENT_BRANCH }}
51
+ fetch-depth : 0
52
+
53
+ - name : setup python
54
+ uses : actions/setup-python@v5
55
+ with :
56
+ python-version : ' 3.9'
57
+ cache : ' pip' # caching pip dependencies
58
+
59
+ - name : install dependencies
60
+ run : |
61
+ pip3 install -r requirements.txt
62
+
63
+ - name : Configure Git User
64
+ run : |
65
+ git config user.name "circleci-runai"
66
+ git config user.email "circleci-runai@run.ai"
67
+
68
+ - name : deploy mkdocs
69
+ run : |
70
+ if [[ "${{ needs.env.outputs.CURRENT_BRANCH }}" == "${{ needs.env.outputs.NEWEST_VERSION }}" ]]; then
71
+ echo "Deploying ${{ needs.env.outputs.NEWEST_VERSION }} as latest..."
72
+ mike list
73
+ git fetch origin gh-pages --depth=1
74
+ mike deploy ${{ needs.env.outputs.CURRENT_BRANCH }} ${{ needs.env.outputs.ALIAS }} latest --title=${{ needs.env.outputs.TITLE }} --push --update-aliases
75
+ mike set-default latest --push
76
+ mike list
77
+ else
78
+ echo "Deploying ${{ needs.env.outputs.CURRENT_BRANCH }} which is not the latest version ( => ${{ needs.env.outputs.NEWEST_VERSION }} )..."
79
+ mike list
80
+ git fetch origin gh-pages --depth=1
81
+ mike deploy ${{ needs.env.outputs.CURRENT_BRANCH }} ${{ needs.env.outputs.ALIAS }} --title=${{ needs.env.outputs.TITLE }} --push
82
+ mike list
83
+ fi
84
+
85
+ slack-notification :
86
+ name : Slack Notification
87
+ needs : [env, install-dependencies-and-deploy]
88
+ if : always()
89
+ runs-on : ubuntu-latest
90
+ steps :
91
+ - name : Slack Notification
92
+ uses : rtCamp/action-slack-notify@v2
93
+ env :
94
+ SLACK_WEBHOOK : ${{ secrets.SLACK_WEBHOOK }}
95
+ SLACK_COLOR : ${{ contains(needs.*.result, 'failure') && 'failure' || 'success' }}
96
+ SLACK_TITLE : " RunAI-Docs: Version ${{ needs.env.outputs.CURRENT_BRANCH }} Deployment ${{ contains(needs.*.result, 'failure') && 'failed' || 'completed successfully' }}"
97
+ SLACK_MESSAGE_ON_SUCCESS : " Docs were updated successfully for version ${{ needs.env.outputs.TITLE }}"
98
+ SLACK_MESSAGE_ON_FAILURE : " Docs update FAILED for version ${{ needs.env.outputs.TITLE }}"
99
+ MSG_MINIMAL : true
100
+ SLACK_FOOTER : " "
0 commit comments