-
Notifications
You must be signed in to change notification settings - Fork 11
68 lines (57 loc) · 2.15 KB
/
update-docs-projects.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
name: Generate documentation
on:
schedule:
- cron: '0 0 * * *' # Launch this workflow everyday at midnight
jobs:
generate-docs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.11.1]
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies with yarn
run: yarn install
- name: Build documentation and check for errors
id: build
run: |
yarn build:remote | tee build.log
if grep -qi "error" build.log; then
echo "error=true" >> "$GITHUB_OUTPUT"
else
echo "error=false" >> "$GITHUB_OUTPUT"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check for changes
id: changes
if: steps.build.outputs.error == 'false'
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
git diff --quiet && git diff --staged --quiet || echo "changed=true" >> "$GITHUB_OUTPUT"
shell: bash
- name: Commit and push if there were changes
if: steps.changes.outputs.changed == 'true'
run: |
git commit -m "Add newly generated documentation"
git push -f origin HEAD:actions-generate-docs
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create PR with updated documentation
if: steps.changes.outputs.changed == 'true'
run: |
PR_EXISTS=$(gh pr view actions-generate-docs --json state -q '.state' || echo "no")
if [ "$PR_EXISTS" = "no" ] || [ "$PR_EXISTS" != "OPEN" ]; then
gh pr create --base main --title "chore(docs): generate documentation" \
--body "This is an auto-generated PR for documentation updates made by GitHub Actions." \
--head actions-generate-docs
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}