Skip to content

api.acmcsuf.com brainstorming [Do not merge] #17

api.acmcsuf.com brainstorming [Do not merge]

api.acmcsuf.com brainstorming [Do not merge] #17

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