forked from SchoolyB/EZ
-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (62 loc) · 1.88 KB
/
sync-errors-doc.yml
File metadata and controls
70 lines (62 loc) · 1.88 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
name: Sync ERRORS.md
on:
pull_request:
branches:
- main
paths:
- 'pkg/errors/codes.go'
push:
branches:
- main
paths:
- 'ERRORS.md'
jobs:
sync:
name: Regenerate ERRORS.md
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
- name: Generate ERRORS.md
run: go run scripts/generate_errors_doc.go
- name: Check for changes
id: check
run: |
if git diff --quiet ERRORS.md; then
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "changed=true" >> $GITHUB_OUTPUT
fi
- name: Commit changes to PR
if: steps.check.outputs.changed == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add ERRORS.md
git commit -m "docs: regenerate ERRORS.md from codes.go"
# Pull latest changes and rebase, then push to current branch
git pull --rebase origin ${{ github.head_ref }}
git push origin HEAD:${{ github.head_ref }}
trigger-docs:
name: Trigger docs sync
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Trigger docs sync
run: |
curl -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.DOCS_REPO_TOKEN }}" \
https://api.github.com/repos/SchoolyB/language.ez/dispatches \
-d '{"event_type":"sync-errors"}'