-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (81 loc) · 2.55 KB
/
godoc.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Print Go API changes
on:
workflow_call:
secrets:
ORG_GH_TOKEN:
required: true
inputs:
go-version:
type: string
default: "1.19"
env:
GOPRIVATE: github.com/TykTechnologies
jobs:
test:
name: Detect Go API changes
runs-on: ubuntu-latest
steps:
- name: Use GitHub Token
env:
TOKEN: ${{ secrets.ORG_GH_TOKEN }}
run: >
git config --global url."https://${TOKEN}@github.com".insteadOf "https://github.com"
- name: Checkout repo
uses: TykTechnologies/github-actions/.github/actions/checkout-pr@main
with:
token: ${{ secrets.ORG_GH_TOKEN }}
- name: Checkout exp
uses: actions/checkout@v3
with:
fetch-depth: 1
repository: TykTechnologies/exp
ref: main
path: exp
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ inputs.go-version }}
- name: Install Task
uses: arduino/setup-task@v1
with:
version: 3
- name: Set up comment author
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Collect API docs
run: |
cp ./exp/.taskfiles/godoc/Taskfile.yml ./Taskfile.godoc.yml
go mod tidy
task -t Taskfile.godoc.yml > current.txt
git checkout -- .
git fetch --depth=1 origin ${{ github.base_ref }}
git checkout ${{ github.base_ref }}
go mod tidy
task -t Taskfile.godoc.yml > prev.txt
- name: Diff API docs
id: api-check
run: |
set +e
diff -u prev.txt current.txt > changes.txt
echo "diff-output<<EOF" >> $GITHUB_OUTPUT
cat changes.txt >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: API Changes
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
API Changes
```diff
${{ steps.api-check.outputs.diff-output || 'no api changes detected' }}
```
edit-mode: replace