-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: automatically update version and changelog for Renovate's PRs (#206)
- Loading branch information
1 parent
7a7a39c
commit a24affd
Showing
5 changed files
with
70 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const fs = require('fs'); | ||
|
||
module.exports = (version, prUrl) => { | ||
const changelog = fs.readFileSync('CHANGELOG.md', 'utf8'); | ||
const changelogLines = changelog.split('\n'); | ||
const lastChangeIndex = changelogLines.findIndex((line) => line.startsWith('## [')); | ||
|
||
const textToAppend = ` | ||
## [${version}] - ${new Date().toISOString().split('T')[0]} | ||
### Dependencies | ||
- chore(deps): update dependencies ([details](${prUrl})) | ||
`.trim(); | ||
|
||
changelogLines.splice(lastChangeIndex, 0, textToAppend + '\n'); | ||
|
||
fs.writeFileSync('CHANGELOG.md', changelogLines.join('\n')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Modify changelog for dependency updates | ||
|
||
on: | ||
pull_request: | ||
types: [labeled] | ||
|
||
jobs: | ||
build: | ||
if: github.event.label.name == 'dependencies' && github.repository == 'KonradSzwarc/devscard' | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Get project information | ||
id: projectinfo | ||
uses: gregoranders/[email protected] | ||
- name: Get next possible versions | ||
id: semvers | ||
uses: WyriHaximus/github-action-next-semvers@v1 | ||
with: | ||
version: ${{ steps.projectinfo.outputs.version }} | ||
- name: Update package.json version | ||
uses: reedyuk/[email protected] | ||
with: | ||
version: ${{ steps.semvers.outputs.patch }} | ||
- name: Update CHANGELOG.md | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const script = require('.github/scripts/update-changelog.js'); | ||
const version = '${{ steps.semvers.outputs.patch }}'; | ||
const prUrl = '${{ github.event.pull_request.url }}'; | ||
script(version, prUrl); | ||
- name: Commit changes | ||
uses: stefanzweifel/git-auto-commit-action@v4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a24affd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Published on https://devscard.netlify.app as production
🚀 Deployed on https://63f6717eaf276c072803ec48--devscard.netlify.app