Skip to content

AMI Release v20250304 #54

AMI Release v20250304

AMI Release v20250304 #54

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@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
with:
repository: awslabs/amazon-eks-ami
ref: refs/heads/main
path: amazon-eks-ami/
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # 7.0.1
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}`;
let updatedChangelog = changelog.replace(placeholder, placeholder + '\n\n' + newEntry + '\n---\n');
// if the release notes are modified in the GitHub web editor, trailing spaces can be added accidentally
updatedChangelog = updatedChangelog.split('\n').map(s => s.replace(/\s+$/, '')).join('\n');
fs.writeFileSync(changelogPath, updatedChangelog);
- uses: peter-evans/create-pull-request@dd2324fc52d5d43c699a5636bcf19fceaa70c284 # 7.0.7
with:
branch: update-changelog
path: amazon-eks-ami/
add-paths: CHANGELOG.md
commit-message: "chore(docs): update CHANGELOG.md for release ${{ needs.setup.outputs.tag_name }}"
committer: "GitHub <[email protected]>"
author: "GitHub <[email protected]>"
title: "chore(docs): update CHANGELOG.md for release ${{ needs.setup.outputs.tag_name }}"
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 }}).