-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
115 lines (107 loc) · 3.1 KB
/
update-documentation.yml
File metadata and controls
115 lines (107 loc) · 3.1 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
name: Update Documentation
on:
workflow_dispatch:
inputs:
tag:
description: 'Release tag (e.g., selenium-4.29.0 or selenium-4.28.1-ruby)'
required: true
type: string
language:
description: 'Language (overrides tag suffix if provided)'
required: false
type: choice
default: "all"
options:
- all
- java
- ruby
- python
- dotnet
- javascript
workflow_call:
inputs:
tag:
required: true
type: string
language:
type: string
default: ""
skip:
description: We're not releasing this one right now
type: boolean
default: false
secrets:
SELENIUM_CI_TOKEN:
required: true
permissions:
contents: write
env:
GITHUB_TOKEN: ${{ github.token }}
jobs:
parse:
name: Parse Tag
if: ${{ !inputs.skip }}
runs-on: ubuntu-latest
outputs:
version: ${{ steps.parse.outputs.version }}
language: ${{ steps.parse.outputs.language }}
steps:
- name: Parse tag
id: parse
env:
TAG: ${{ inputs.tag }}
INPUT_LANG: ${{ inputs.language }}
run: |
echo "version=$(echo "$TAG" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')" >> "$GITHUB_OUTPUT"
# Extract language from tag suffix or use input
if [ -n "$INPUT_LANG" ] && [ "$INPUT_LANG" != "all" ]; then
LANG="$INPUT_LANG"
elif [[ "$TAG" =~ -(javascript|python|ruby|java|dotnet)$ ]]; then
LANG="${BASH_REMATCH[1]}"
else
LANG="all"
fi
echo "language=$LANG" >> "$GITHUB_OUTPUT"
generate-docs:
name: Generate Documentation
needs: parse
if: ${{ !inputs.skip }}
uses: ./.github/workflows/bazel.yml
with:
name: Generate Docs
ref: ${{ inputs.tag }}
run: ./go ${{ needs.parse.outputs.language }}:docs
artifact-name: documentation
artifact-path: build/docs/api/**/*
commit-docs:
name: Commit Documentation
needs: [parse, generate-docs]
if: ${{ !inputs.skip }}
runs-on: ubuntu-latest
steps:
- name: Checkout gh-pages
uses: actions/checkout@v4
with:
ref: gh-pages
token: ${{ secrets.SELENIUM_CI_TOKEN || github.token }}
- name: Download documentation
uses: actions/download-artifact@v4
with:
name: documentation
- name: Setup git
run: |
git config --local user.email "selenium-ci@users.noreply.github.com"
git config --local user.name "Selenium CI Bot"
- name: Commit documentation
run: |
git add docs/api/
if git diff --staged --quiet; then
echo "No documentation changes to commit"
else
git commit -m "Update ${{ needs.parse.outputs.language }} documentation for Selenium ${{ needs.parse.outputs.version }}"
for _ in 1 2; do
git pull --rebase origin gh-pages && git push origin gh-pages && exit 0
sleep 2
done
exit 1
fi