Skip to content
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

[Build] Add maestro-changelog workflow action #11757

Merged
merged 1 commit into from
Dec 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/maestro-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Add changelog for Maestro bump
on: pull_request

jobs:
add-changelog:
name: Add changelog
runs-on: ubuntu-latest
if: github.actor == 'dotnet-maestro[bot]'

steps:
- name: 'Compute changelog'
run: |
set -exo pipefail
git clone https://github.com/spouliot/dotnet-tools
cd dotnet-tools/changelog
dotnet run https://github.com/$GITHUB_REPOSITORY/pull/${GITHUB_REF_NAME/\/*/} > changelog.txt 2>&1

# need to replace newlines with actual "\n"
rm -f changelog2.txt
echo "CHANGELOG_MESSAGE<<EOF" >> changelog2.txt
cat changelog.txt | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/\\n/g' >> changelog2.txt
echo EOF >> changelog2.txt
cat changelog2.txt

# export the changelog message
cat changelog2.txt >> $GITHUB_ENV

- name: 'Add changelog'
uses: actions/github-script@v6.3.3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
// check if we've already added a changelog to this PR, and if so, update that comment, otherwise add a new comment
var commentId = ""
await github.paginate (github.rest.issues.listComments,
{
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
}).then ((comments) =>
{
const changelogComment = comments.find(comment => comment.body.includes (".net ChangeLog for") && comment.user.login == 'github-actions[bot]')
if (changelogComment)
commentId = changelogComment.id
})
if (commentId == "") {
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: '${{ env.CHANGELOG_MESSAGE }}'
})
} else {
github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: commentId,
body: '${{ env.CHANGELOG_MESSAGE }}'
})
}