This repository has been archived by the owner on Sep 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
100 lines (80 loc) · 2.66 KB
/
diff.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
98
99
100
name: Diff output
on: pull_request
jobs:
build-proposed:
runs-on: ubuntu-latest
steps:
- name: Install go
uses: actions/setup-go@v2
with:
go-version: '1.16.x'
- name: Checkout PR branch
uses: actions/checkout@v2
- name: Build binary
run: CGO_ENABLED=0 GO111MODULE=on go install ./http-api-docs
- name: Run http-api-docs
run: http-api-docs > http-api-docs-proposed.md
- run: cat http-api-docs-proposed.md
- uses: actions/upload-artifact@v2
with:
name: http-api-docs-proposed.md
path: http-api-docs-proposed.md
build-current:
runs-on: ubuntu-latest
steps:
- name: Install go
uses: actions/setup-go@v2
with:
go-version: '1.16.x'
- name: Checkout default branch
uses: actions/checkout@v2
with:
ref: master
- name: Build binary
run: CGO_ENABLED=0 GO111MODULE=on go install ./http-api-docs
- name: Run http-api-docs
run: http-api-docs > http-api-docs-current.md
- run: cat http-api-docs-current.md
- uses: actions/upload-artifact@v2
with:
name: http-api-docs-current.md
path: http-api-docs-current.md
diff:
needs: [build-current, build-proposed]
runs-on: ubuntu-latest
steps:
- name: Download proposed output
uses: actions/download-artifact@v2
with:
name: http-api-docs-proposed.md
- name: Download current output
uses: actions/download-artifact@v2
with:
name: http-api-docs-current.md
# gir diff exists with an error if there is a diff... so we ignore that here.
- name: Diff the outputs
run: git diff --no-index --output diff.txt http-api-docs-current.md http-api-docs-proposed.md || true
- run: cat diff.txt
- uses: actions/upload-artifact@v2
with:
name: http-api-docs-diff.txt
path: diff.txt
- name: Prepare diff for comment
id: diff
run: |
body=$(cat diff.txt)
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo ::set-output name=body::$body
- name: Add diff as PR comment
uses: peter-evans/create-or-update-comment@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
issue-number: ${{ github.event.number }}
body: |
Diff of http-api-docs output:
```diff
${{ steps.diff.outputs.body }}
```