Skip to content

Commit b5a6c00

Browse files
[NIT-4309] CI: Create changelog fragment for dependabot PRs (#4219)
* Changelog * New workflow * Let's try it for this PR firstly * Add a changelog entry for dependabot update * Seems like it's working. Restoring the author filter then * Remove the added changelog fragment --------- Co-authored-by: Pepper Lebeck-Jobe <[email protected]>
1 parent dc6debc commit b5a6c00

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Changelog fragments for automated PRs
2+
3+
on:
4+
pull_request:
5+
types: [opened]
6+
7+
jobs:
8+
add-changelog:
9+
# Only run if the PR is opened by dependabot
10+
if: github.actor == 'dependabot[bot]'
11+
runs-on: ubuntu-4
12+
permissions:
13+
contents: write
14+
15+
steps:
16+
- name: Checkout Code
17+
uses: actions/checkout@v6
18+
19+
- name: Create Changelog File
20+
uses: actions/github-script@v8
21+
with:
22+
script: |
23+
const fs = require('fs');
24+
const path = require('path');
25+
26+
const dir = 'changelog';
27+
28+
// Find the next available number
29+
let x = 1;
30+
while (fs.existsSync(path.join(dir, `dependabot-${x}.md`))) {
31+
x++;
32+
}
33+
34+
const filename = path.join(dir, `dependabot-${x}.md`);
35+
const title = context.payload.pull_request.title;
36+
const content = `### Ignored\n- ${title}\n`;
37+
38+
fs.writeFileSync(filename, content);
39+
console.log(`Created ${filename} for PR: ${title}`);
40+
41+
- name: Commit and Push
42+
uses: stefanzweifel/git-auto-commit-action@v7
43+
with:
44+
commit_message: "Add a changelog entry for dependabot update"
45+
file_pattern: 'changelog/dependabot-*.md'

changelog/pmikolajczyk-nit-4309.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### Ignored
2+
- Automatically create changelog fragment for dependabot PRs

0 commit comments

Comments
 (0)