-
Notifications
You must be signed in to change notification settings - Fork 29
93 lines (84 loc) · 3.17 KB
/
deploy_doc.yml
File metadata and controls
93 lines (84 loc) · 3.17 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
name: Deploy SDK doc
on:
workflow_dispatch:
inputs:
branch:
description: "Deploy doc of which branch?"
required: false
type: string
default: "main"
workflow_call: # called from publish.yml
secrets:
SLACK_WEBHOOK_URL_PYTHON_SDK:
required: true
jobs:
deploy-documentation:
name: Deploy technical documentation
runs-on: ubuntu-latest
steps:
- name: set checkout branch
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "REF=${{ github.event.inputs.branch }}" >> $GITHUB_ENV
else
# Use the release that triggered this workflow, not the "latest" release
release_branch="${{ github.event.release.target_commitish }}"
tag_name="${{ github.ref_name }}"
echo "Release tag: $tag_name"
echo "Release branch: $release_branch"
sanitized_version=${tag_name#v}
major_minor=$(echo "$sanitized_version" | awk -F. '{print $1 "." $2}')
if [[ "$release_branch" == "main" ]]; then
echo "REF=main" >> $GITHUB_ENV
else
echo "REF=release/$major_minor" >> $GITHUB_ENV
fi
fi
- uses: actions/checkout@v4
with:
ref: ${{ env.REF }} # checked out branch
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10 || 3.14"
cache: "pip"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: setup git
run: |
git config user.name github-actions
git config user.email github-actions@github.com
- name: Deploy doc
run: |
export version=$(python -c 'from kili import __version__; print(".".join(__version__.split(".")[:2]))') # removes patch suffix
git fetch origin gh-pages --depth=1
if [[ "${{ env.REF }}" == "main" ]]; then
# Only update "latest" alias for releases from main branch
mike deploy --push --update-aliases $version latest
else
# Maintenance releases: update version docs without changing "latest" alias
mike deploy --push $version
fi
- name: Slack notification
id: slack
if: success()
uses: slackapi/slack-github-action@v1.25.0
with:
payload: |
{
"text": "Kili technical documentation released: https://python-sdk-docs.kili-technology.com/. \nA Hard refresh may be useful to see the latest version",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Kili technical documentation released: https://python-sdk-docs.kili-technology.com/. \nA Hard refresh may be useful to see the latest version"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_PYTHON_SDK }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK