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

feat(governance): Automatically remind governance team to update unreleased_changelog.md. #3342

Merged
64 changes: 64 additions & 0 deletions .github/workflows/governance_pull_request_template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Remind Governance Team to Update unreleased_changelog.md.
daniel-wong-dfinity-org marked this conversation as resolved.
Show resolved Hide resolved

on:
pull_request:
types:
daniel-wong-dfinity-org marked this conversation as resolved.
Show resolved Hide resolved
- labeled

jobs:
mainJob:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
id: mainStep
if: contains(github.event.pull_request.labels.*.name, '@nns-team')
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
retries: 3
script: |
const pullRequestNumber = context.payload.number;

// Skip reminder if we already reminded (to avoid spam).
const reviews = await github.rest.pulls.listReviews({
owner: "dfinity",
repo: "ic",
pull_number: pullRequestNumber,
});
const alreadyRemindedAboutUnreleasedChangelog = reviews
.data
.some(review => review
.body
.startsWith("If this pull request affects the behavior of any canister owned by")
);
console.log("alreadyRemindedAboutUnreleasedChangelog = " + alreadyRemindedAboutUnreleasedChangelog);
if (alreadyRemindedAboutUnreleasedChangelog) {
return;
}

// Post a review to remind the author to update unreleased_changelog.md.
// TODO: Figure out how to post in such a way that there is a "Resolve" button nearby.
console.log("Adding reminder to update unreleased_changelog.md...");
const reminderText = `
If this pull request affects the behavior of any canister owned by
the Governance team, remember to update the corresponding
unreleased_changes.md file(s).

To acknowldge this reminder (and unblock the PR), dismiss this
code review by going to the bottom of the pull request page, and
supply one of the following reasons:

1. Done.

2. No canister behavior changes.
`
.replace(/^ +/gm, '')
.trim();
await github.rest.pulls.createReview({
owner: "dfinity",
repo: "ic",
pull_number: pullRequestNumber,
body: reminderText,
// This is what forces the author to explicitly acknowledge.
event: "REQUEST_CHANGES",
});
console.log("Reminder was added successfully.");
Loading