-
Notifications
You must be signed in to change notification settings - Fork 1.1k
76 lines (71 loc) 路 2.25 KB
/
on-pr-changelog.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
name: PR Changelog
permissions:
# To add and edit comments on PRs
contents: read
pull-requests: write
on:
workflow_call:
inputs:
ref:
required: true
description: "GitHub ref to use, must be the merge ref of the pull request"
type: string
base-ref:
required: true
description: "GitHub base ref, the base ref of the pull request"
type: string
pr-number:
required: true
description: "PR number to use"
type: string
changelog-required:
required: true
description: "Whether the changelog is required, used to allow check to pass on empty changelogs"
type: boolean
secrets:
PULUMI_BOT_TOKEN:
required: true
description: "GitHub access token, required to mitigate GitHub rate limits"
defaults:
run:
shell: bash
jobs:
check:
name: comment
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.PULUMI_BOT_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: '>=1.19.0' # decoupled from version sets, only used by changelog tool
- name: Changelog
id: changelog
env:
GITHUB_PR: ${{ inputs.pr-number }}
PREVIOUS_VERSION: ${{ inputs.base-ref }}
CHANGELOG_REQUIRED: ${{ inputs.changelog-required }}
run: |
CHANGELOG="$(./.github/scripts/get-changelog-comment "${PREVIOUS_VERSION}" "${CHANGELOG_REQUIRED}" "${GITHUB_PR}")"
./.github/scripts/set-output CHANGELOG "${CHANGELOG}"
- name: Find Comment
uses: peter-evans/find-comment@v3
id: fc
with:
token: ${{ secrets.PULUMI_BOT_TOKEN }}
issue-number: ${{ inputs.pr-number }}
body-includes: "# Changelog"
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.PULUMI_BOT_TOKEN }}
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ inputs.pr-number }}
body: |
# Changelog
${{ fromJSON(steps.changelog.outputs.CHANGELOG) }}
edit-mode: replace