Skip to content

Commit 2b14a12

Browse files
[ci] Enabled openwisp-utils changelog bot #495
Enabled the new changelog bot which automatically posts a proposed change log entry as a comment when PRs are approved, which maintainers can copy/paste when squash merging. Closes #495
1 parent 7f3d674 commit 2b14a12

2 files changed

Lines changed: 92 additions & 0 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Changelog Bot Runner
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Changelog Bot Trigger"]
6+
types:
7+
- completed
8+
9+
permissions:
10+
actions: read
11+
12+
jobs:
13+
fetch-metadata:
14+
runs-on: ubuntu-latest
15+
if: github.event.workflow_run.conclusion == 'success'
16+
permissions:
17+
actions: read
18+
outputs:
19+
pr_number: ${{ steps.metadata.outputs.pr_number }}
20+
steps:
21+
- name: Download PR metadata
22+
id: download
23+
uses: actions/download-artifact@v8
24+
with:
25+
name: changelog-metadata
26+
github-token: ${{ secrets.GITHUB_TOKEN }}
27+
run-id: ${{ github.event.workflow_run.id }}
28+
continue-on-error: true
29+
30+
- name: Read PR metadata
31+
if: steps.download.outcome == 'success'
32+
id: metadata
33+
run: |
34+
PR_NUMBER=$(cat pr_number)
35+
if ! [[ "$PR_NUMBER" =~ ^[0-9]+$ ]]; then
36+
echo "::error::Invalid PR number: $PR_NUMBER"
37+
exit 1
38+
fi
39+
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
40+
41+
changelog:
42+
needs: fetch-metadata
43+
if: needs.fetch-metadata.outputs.pr_number != ''
44+
permissions:
45+
contents: read
46+
pull-requests: write
47+
issues: write
48+
uses: openwisp/openwisp-utils/.github/workflows/reusable-bot-changelog.yml@master
49+
with:
50+
pr_number: ${{ needs.fetch-metadata.outputs.pr_number }}
51+
secrets:
52+
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
53+
OPENWISP_BOT_APP_ID: ${{ secrets.OPENWISP_BOT_APP_ID }}
54+
OPENWISP_BOT_PRIVATE_KEY: ${{ secrets.OPENWISP_BOT_PRIVATE_KEY }}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Changelog Bot Trigger
2+
3+
on:
4+
pull_request_review:
5+
types: [submitted]
6+
7+
permissions: {}
8+
9+
jobs:
10+
check:
11+
if: |
12+
github.event.review.state == 'approved' &&
13+
(github.event.review.author_association == 'OWNER' ||
14+
github.event.review.author_association == 'MEMBER' ||
15+
github.event.review.author_association == 'COLLABORATOR')
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Check for noteworthy PR
19+
id: check
20+
env:
21+
PR_TITLE: ${{ github.event.pull_request.title }}
22+
run: |
23+
if echo "$PR_TITLE" | grep -qiE '^\[(feature|fix|change)\]'; then
24+
echo "has_noteworthy=true" >> $GITHUB_OUTPUT
25+
fi
26+
27+
- name: Save PR metadata
28+
if: steps.check.outputs.has_noteworthy == 'true'
29+
env:
30+
PR_NUMBER: ${{ github.event.pull_request.number }}
31+
run: echo "$PR_NUMBER" > pr_number
32+
33+
- name: Upload PR metadata
34+
if: steps.check.outputs.has_noteworthy == 'true'
35+
uses: actions/upload-artifact@v7
36+
with:
37+
name: changelog-metadata
38+
path: pr_number

0 commit comments

Comments
 (0)