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
|
name: Update Changelog
on:
workflow_dispatch:
inputs:
type:
description: "Type of when to retreive commits from"
options: ["date", "tag", "commit"]
required: true
type: choice
default: "date"
start:
description: "Date '2021-01-01' or tag 'v1.0.0' or commit 'sha'"
required: true
changelog_path:
description: "Changelog path"
required: true
default: "CHANGELOG.md"
prefix:
description: "Prefix for the branch with PR"
required: true
default: "changelog-for-"
env:
GH_TOKEN: ${{ secrets.YDBOT_TOKEN }}
jobs:
gather-prs:
runs-on: ubuntu-latest
outputs:
prs: ${{ steps.pr-list.outputs.prs }}
steps:
- name: Check out repository
uses: actions/checkout@v5
- name: Get merged PRs
id: pr-list
run: |
TYPE="${{ github.event.inputs.type }}"
START="${{ github.event.inputs.start }}"
BRANCH="${GITHUB_REF_NAME}"
echo "::notice:: branch = ${GITHUB_REF_NAME}, start = $START"
if [ "$TYPE" == "date" ]; then
echo "Getting PRs since date: $START"
PRS=$(gh pr list -L 1000 --state merged --json number,title,baseRefName,mergedAt --jq ".[] | select(.baseRefName == \"$BRANCH\" and .mergedAt >= \"$START\") | {id: .number}" | jq -c -s ".")
elif [ "$TYPE" == "tag" ]; then
echo "Fetching tags from remote"
git fetch --tags
echo "Getting PRs since tag: $START"
COMMIT=$(git rev-list -n 1 $START)
PRS=$(gh pr list -L 1000 --state merged --json number,title,baseRefName,mergedAt --jq ".[] | select(.baseRefName == \"$BRANCH\" and .mergeCommit.oid >= \"$COMMIT\") | {id: .number}" | jq -c -s ".")
elif [ "$TYPE" == "commit" ]; then
echo "Getting PRs since commit: $START"
PRS=$(gh pr list -L 1000 --state merged --json number,title,baseRefName,mergedAt --jq ".[] | select(.baseRefName == \"$BRANCH\" and .mergeCommit.oid >= \"$START\") | {id: .number}" | jq -c -s ".")
else
echo "::error::Invalid type: $TYPE"
exit 1
fi
if [ -z "$PRS" ]; then
PRS="[]"
fi
echo "$PRS" > prs.json
echo "prs=$PRS" >> "$GITHUB_OUTPUT"
- name: Debug PR list output
run: |
cat prs.json
- name: Upload PRs JSON
uses: actions/upload-artifact@v6
with:
name: prs-json
path: prs.json
update-changelog:
needs: gather-prs
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v5
- name: Update Changelog
uses: ./.github/actions/update_changelog
env:
GH_TOKEN: ${{ secrets.YDBOT_TOKEN }}
with:
pr_data: "${{ needs.gather-prs.outputs.prs }}"
changelog_path: "${{ github.event.inputs.changelog_path }}"
base_branch: "${GITHUB_REF_NAME}"
suffix: "${{ github.event.inputs.start }}"
|