-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CHANGELOG workflow #1467
Merged
Merged
Add CHANGELOG workflow #1467
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
23200ee
Add named arguments to bot
cartermckinnon 0618181
Merge branch 'awslabs:master' into master
cartermckinnon 3016163
Update README for bot
cartermckinnon e4fc777
Add reply for bad input
cartermckinnon d7f0c93
Add changelog workflow
cartermckinnon fff4aaa
Merge branch 'awslabs:master' into master
cartermckinnon 465d1dc
Add changelog workflow
cartermckinnon 07d14fd
Swap awslabs -> cartermckinnon for a final test
73a8196
Fix contains -> includes
349fa8f
Swap cartermckinnon -> awslabs, test succeeded
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,60 @@ | ||
name: "[Release] Update CHANGELOG.md" | ||
on: | ||
release: | ||
types: [released] | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
jobs: | ||
setup: | ||
# this workflow will always fail in forks; bail if this isn't running in the upstream | ||
if: github.repository == 'awslabs/amazon-eks-ami' | ||
runs-on: ubuntu-latest | ||
outputs: | ||
tag_name: ${{ steps.variables.outputs.tag_name }} | ||
steps: | ||
- id: variables | ||
run: | | ||
echo "tag_name=$(echo ${{ github.ref }} | cut -d/ -f3)" >> $GITHUB_OUTPUT | ||
update-changelog: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- setup | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
repository: awslabs/amazon-eks-ami | ||
ref: refs/heads/master | ||
path: amazon-eks-ami/ | ||
- uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const fs = require('fs'); | ||
const changelogPath = './amazon-eks-ami/CHANGELOG.md'; | ||
const placeholder = '<!--new-changelog-entry-placeholder-->'; | ||
const tagName = '${{ needs.setup.outputs.tag_name }}'; | ||
const release = await github.rest.repos.getReleaseByTag({ | ||
tag: tagName, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
}); | ||
const changelog = fs.readFileSync(changelogPath, 'utf8'); | ||
if (changelog.includes(release.data.name)) { | ||
throw new Error(`changelog already includes ${release.data.name}`); | ||
} | ||
const newEntry = `### ${release.data.name}\n${release.data.body}`; | ||
const updatedChangelog = changelog.replace(placeholder, placeholder + '\n\n' + newEntry); | ||
fs.writeFileSync(changelogPath, updatedChangelog); | ||
- uses: peter-evans/create-pull-request@v4 | ||
with: | ||
branch: update-changelog | ||
path: amazon-eks-ami/ | ||
add-paths: CHANGELOG.md | ||
commit-message: "Update CHANGELOG.md for release ${{ needs.setup.outputs.tag_name }}" | ||
committer: "GitHub <noreply@github.com>" | ||
author: "GitHub <noreply@github.com>" | ||
title: "Update CHANGELOG.md" | ||
labels: | | ||
changelog/exclude | ||
body: | | ||
Adds CHANGELOG.md entry for release [${{ needs.setup.outputs.tag_name }}](https://github.com/awslabs/amazon-eks-ami/releases/tag/${{ needs.setup.outputs.tag_name }}). |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We should verify that the changelog doesn't already have the release before we add it to ensure that this workflow is idempotent. If it fails, we'd ideally open a github issue.
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.
I added a check for the release title. We'll get an email if this workflow fails, I could open an issue if you feel strongly about it
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.
Not really. I think that the changelog has limited value, if any, since it's already in the release notes and now it's just a formatted list of commits and version information.