-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (63 loc) · 2.64 KB
/
docs.yml
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
# A GitHub Actions workflow that generates the documentation for pull requests
name: Documentation
on:
push:
jobs:
docs:
runs-on: ubuntu-20.04
# In order to trigger the CLA after committing docs changes, we need
# to use the GIX_CREATE_PR_PAT token. This token is not available for all
# users. So on PRs where the token is not available, we don't commit
# changes and instead just fail if the docs changes are needed.
steps:
- name: Check if commits can be added
id: check_can_add_commit
run: |
echo "can_add_commit=${{ secrets.GIX_CREATE_PR_PAT != '' && github.event_name == 'pull_request' }}" >> $GITHUB_OUTPUT
- name: Checkout with token
if: steps.check_can_add_commit.outputs.can_add_commit == 'true'
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.GIX_CREATE_PR_PAT }}
- name: Checkout without token
if: steps.check_can_add_commit.outputs.can_add_commit == 'false'
uses: actions/checkout@v4
- name: Prepare
uses: ./.github/actions/prepare
- name: Build
run: npm run build
- name: Generate docs
run: npm run docs
- name: Commit docs
uses: EndBug/add-and-commit@v9
# We don't want to commit documentation changes to main
if: ${{ github.ref != 'refs/heads/main' }}
with:
add: .
default_author: github_actions
message: "🤖 Documentation auto-update"
- name: Check docs changes
id: check_docs
run: |
if git diff --exit-code; then
echo "docs_needed=false" >> $GITHUB_OUTPUT
else
echo "docs_needed=true" >> $GITHUB_OUTPUT
fi
- name: Commit docs changes
if: steps.check_can_add_commit.outputs.can_add_commit == 'true' && steps.check_docs.outputs.docs_needed == 'true'
uses: EndBug/[email protected]
with:
add: .
default_author: github_actions
message: "Updating docs"
# do not pull: if this branch is behind, then we might as well let
# the pushing fail
pull_strategy: "NO-PULL"
- name: Fail for docs issues without personal access token
if: steps.check_can_add_commit.outputs.can_add_commit == 'false' && steps.check_docs.outputs.formatting_needed == 'true'
run: |
echo "Docs changes are needed but couldn't be committed because the personal access token isn't available or this isn't a pull request."
exit 1