-
-
Notifications
You must be signed in to change notification settings - Fork 33
193 lines (172 loc) · 6.19 KB
/
docs.yml
File metadata and controls
193 lines (172 loc) · 6.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: Docs Update
on:
push:
branches:
- master
paths:
- 'docs/**'
- 'mkdocs.yml'
- '.mike.yml'
- 'README.md'
- 'CODE_OF_CONDUCT.md'
- 'CONTRIBUTING.md'
- 'LICENSE'
- 'SECURITY.md'
- 'CHANGELOG.md'
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
env:
GOOGLE_ANALYTICS_KEY: ${{ secrets.GOOGLE_ANALYTICS_KEY }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Send Initial Slack Message
id: send_initial_slack_docs
uses: rennf93/good-comms@master
with:
SLACK_WEBHOOK: '${{ secrets.SLACK_WEBHOOK }}'
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
STATUS: 'Started'
CHANNEL_ID: '${{ secrets.SLACK_CHANNEL }}'
AUTHOR_NAME: 'FastAPI Guard - Docs Update'
AUTHOR_LINK: 'https://github.com/rennf93/fastapi-guard'
AUTHOR_ICON: ':books:'
TITLE: 'Docs Update Started'
TITLE_LINK: 'https://github.com/rennf93/fastapi-guard/actions'
MESSAGE: |
.
*DOCS UPDATE TRIGGERED!*
.
Current Docs version:
${{ secrets.DOCS_VERSION }}
.
Commit:
${{ github.event.head_commit.message }}
.
COLOR: warning
- uses: actions/setup-python@v6
with:
python-version: 3.x
- name: Install dependencies
run: |
pip install mkdocs-material
pip install "mkdocstrings[python]"
pip install mike
pip install pymarkdownlnt
pip install yq
pip install -e .
- name: Lint documentation
run: |
pymarkdownlnt scan -r -e ./.venv -e ./.git -e ./.github -e ./data -e ./guard -e ./tests .
- name: Configure Git user
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Get and Update Version
id: get_version
run: |
CURRENT_VERSION=$(yq -r '.aliases.latest' .mike.yml)
if [[ ! $CURRENT_VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Invalid version format in .mike.yml: $CURRENT_VERSION"
exit 1
fi
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
if [[ -n "${{ secrets.DOCS_VERSION }}" ]]; then
STORED_VERSION=${{ secrets.DOCS_VERSION }}
echo "STORED_VERSION=$STORED_VERSION" >> $GITHUB_ENV
else
echo "::error::DOCS_VERSION secret not found"
exit 1
fi
if [[ "$CURRENT_VERSION" != "$STORED_VERSION" ]]; then
echo "::notice::Updating DOCS_VERSION from $STORED_VERSION to $CURRENT_VERSION"
echo "VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
echo "UPDATE_SECRET=true" >> $GITHUB_ENV
else
echo "::notice::Versions match ($CURRENT_VERSION), no update needed"
echo "VERSION=$STORED_VERSION" >> $GITHUB_ENV
echo "UPDATE_SECRET=false" >> $GITHUB_ENV
fi
- name: Update Docs Version Secret
if: ${{ env.UPDATE_SECRET == 'true' }}
uses: rennf93/github-actions-secrets-mgmt@v1.5
with:
OWNER: ${{ github.repository_owner }}
REPOSITORY: ${{ github.event.repository.name }}
ACCESS_TOKEN: ${{ secrets.PAT_TOKEN }}
SECRET_NAME: DOCS_VERSION
SECRET_VALUE: ${{ env.VERSION }}
- name: Deploy documentation
run: |
mike deploy --push ${{ env.VERSION }}
mike alias --update-aliases --push ${{ env.VERSION }} latest
mike set-default --push latest
- name: Deploy to GitHub Pages
run: |
mike list
git push origin gh-pages --force
- name: Update Context7 Documentation
id: context7
uses: rennf93/upsert-context7@1.1
with:
operation: refresh
- name: Show result
run: |
echo "Success: ${{ steps.context7.outputs.success }}"
echo "Status: ${{ steps.context7.outputs.status-code }}"
echo "Message: ${{ steps.context7.outputs.message }}"
- name: Notify Success on Slack Channel
uses: rennf93/good-comms@master
with:
SLACK_WEBHOOK: '${{ secrets.SLACK_WEBHOOK }}'
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
STATUS: 'Success'
CHANNEL_ID: '${{ secrets.SLACK_CHANNEL }}'
AUTHOR_NAME: 'FastAPI Guard - Docs Update'
AUTHOR_LINK: 'https://github.com/rennf93/fastapi-guard'
AUTHOR_ICON: ':gem:'
TITLE: 'Docs Update Successful'
TITLE_LINK: 'https://github.com/rennf93/fastapi-guard/actions'
MESSAGE: |
.
*Docs v${{ env.VERSION }} Update Successful!*
.
Commit message:
${{ github.event.head_commit.message }}
Commit URL:
${{ github.event.head_commit.url }}
.
COLOR: good
SLACK_THREAD_TS: ${{ steps.send_initial_slack_docs.outputs.SLACK_THREAD_TS }}
- name: Send Failure Notification to Slack
if: failure()
uses: rennf93/good-comms@master
with:
SLACK_WEBHOOK: '${{ secrets.SLACK_WEBHOOK }}'
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
STATUS: 'Failed'
CHANNEL_ID: '${{ secrets.SLACK_CHANNEL }}'
AUTHOR_NAME: 'FastAPI Guard - Docs Update'
AUTHOR_LINK: 'https://github.com/rennf93/fastapi-guard'
AUTHOR_ICON: ':skull:'
TITLE: 'Docs Update Failed'
TITLE_LINK: 'https://github.com/rennf93/fastapi-guard/actions'
MESSAGE: |
.
*Docs v${{ env.VERSION }} Update Failed!*
.
Docs Update failed for commit:
${{ github.event.head_commit.message }}
Commit URL:
${{ github.event.head_commit.url }}
Please check the logs for more details.
.
COLOR: danger
SLACK_THREAD_TS: ${{ steps.send_initial_slack_docs.outputs.SLACK_THREAD_TS }}