-
Notifications
You must be signed in to change notification settings - Fork 2
53 lines (45 loc) · 1.72 KB
/
godoc_pr_preview.yaml
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
name: Request Go Documentation
on:
pull_request:
types:
- opened
- synchronize
jobs:
request-documentation:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.21
- name: Fetch module version
id: generate-comment
run: |
version=$(go mod download -json "$REPO@$REV" | jq -r .Version)
echo "Module version: $version"
echo "name=$version" >> "$GITHUB_OUTPUT"
link="https://pkg.go.dev/$REPO@$version"
comment="Documentation for this module: [GoDoc]($link)"
echo "comment=$(jq -n --arg s \"$comment\" '$s')" >> "$GITHUB_OUTPUT"
env:
REPO: ${{ github.repository.full_name }}
REV: ${{ github.event.pull_request.base.sha }}
- name: Update existing issue comment
uses: peter-evans/find-comment@v1
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: ${{ fromJSON(steps.generate-comment.outputs.comment) }}
- name: Create or update comment
if: steps.fc.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.pull_request.number }}
body: ${{ fromJSON(steps.generate-comment.outputs.comment) }}
- name: Update comment
if: steps.fc.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
body: ${{ fromJSON(steps.generate-comment.outputs.comment) }}