1
1
name : Update Changelog
2
2
3
3
on :
4
- pull_request :
5
- types : [opened, edited ]
4
+ issue_comment :
5
+ types : [created ]
6
6
7
7
jobs :
8
8
update-changelog :
9
- # Only run if this is not a PR from a fork to avoid permission issues
10
- # and not a commit made by GitHub Action to avoid infinite loops
11
- if : github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'github-actions[bot]'
9
+ # Only run if this is a comment on a PR containing "@actions-user changelog"
10
+ # and not a comment made by GitHub Action to avoid infinite loops
11
+ if : github.event.issue. pull_request && contains(github.event.comment.body, '@actions-user changelog') && github.actor != 'github-actions[bot]'
12
12
runs-on : ubuntu-latest
13
13
permissions :
14
14
contents : write
15
15
pull-requests : write
16
16
17
17
steps :
18
+ - name : Get PR details
19
+ id : pr-details
20
+ uses : actions/github-script@v7
21
+ with :
22
+ script : |
23
+ const { data: pullRequest } = await github.rest.pulls.get({
24
+ owner: context.repo.owner,
25
+ repo: context.repo.repo,
26
+ pull_number: context.issue.number
27
+ });
28
+ core.setOutput('number', pullRequest.number);
29
+ core.setOutput('title', pullRequest.title);
30
+ core.setOutput('head_ref', pullRequest.head.ref);
31
+
18
32
- name : Checkout repository
19
33
uses : actions/checkout@v4
20
34
with :
21
35
# Checkout the PR head ref
22
- ref : ${{ github.event.pull_request.head.ref }}
36
+ ref : ${{ steps.pr-details.outputs.head_ref }}
23
37
token : ${{ secrets.GITHUB_TOKEN }}
24
38
25
39
- name : Set up Python
30
44
- name : Update changelog
31
45
run : |
32
46
python modify_changelog.py update_changelog \
33
- "${{ github.event.pull_request .number }}" \
34
- " ${{ github.event.pull_request .title }}"
47
+ "${{ steps.pr-details.outputs .number }}" \
48
+ ' ${{ steps.pr-details.outputs .title }}'
35
49
36
50
- name : Check for changes
37
51
id : changes
48
62
git config --local user.email "[email protected] "
49
63
git config --local user.name "GitHub Action"
50
64
git add docs/changelog.md
51
- git commit -m "Add changelog entry for PR #${{ github.event.pull_request .number }}"
65
+ git commit -m "Add changelog entry for PR #${{ steps.pr-details.outputs .number }}"
52
66
git push
0 commit comments