-
Notifications
You must be signed in to change notification settings - Fork 2
57 lines (49 loc) · 1.87 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
54
55
56
57
name: godoc_pr_preview
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: Generate comment
id: generate_comment
run: |
set -x
version=$(go mod download --json $REPO@$REV | jq -r .Version)
echo "Module version: $version"
echo "version=$version" >> "$GITHUB_OUTPUT"
link="https://godocs.io/$REPO@$version"
comment="### godoc reference preview ready ✨<br>[![Go Documentation](https://godocs.io/github.com/acmcsufoss/api.acmcsuf.com?status.svg)]($link)"
echo "comment=$comment" >> "$GITHUB_OUTPUT"
env:
REPO: github.com/${{ github.event.pull_request.base.repo.full_name }}
REV: ${{ github.event.pull_request.head.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: "### godoc reference preview ready ✨"
edit-mode: replace
- 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: ${{ steps.generate_comment.outputs.comment }}
edit-mode: replace
- 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: ${{ steps.generate_comment.outputs.comment }}
edit-mode: replace