-
Notifications
You must be signed in to change notification settings - Fork 29
87 lines (78 loc) · 2.93 KB
/
deploy_doc.yml
File metadata and controls
87 lines (78 loc) · 2.93 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
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=$branch" >> $GITHUB_ENV
else
release_payload=$(curl --silent "https://api.github.com/repos/kili-technology/kili-python-sdk/releases/latest")
last_version=$(echo "$release_payload" | jq -r .tag_name)
echo "Last version: $last_version"
release_branch=$(echo "$release_payload" | jq -r .target_commitish)
echo "Release branch: $release_branch"
sanitized_version=${last_version#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.9
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
mike deploy --push --update-aliases $version latest
- 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