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

GH action script for commenting on issues when related milestone is c… #11

Merged
merged 1 commit into from
Dec 4, 2023
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
27 changes: 13 additions & 14 deletions .github/workflows/comment-milestoned-issues.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Comment when milestone is closed
on:
issues:
types: [milestoned]
milestone:
types: [closed]

jobs:
comment:
Expand All @@ -11,24 +11,23 @@ jobs:
uses: actions/github-script@v5
with:
script: |
const issue_number = context.issue.number;
const milestone_title = context.payload.issue.milestone.title;
// Get all milestones
const milestones = await github.rest.issues.listMilestones({
const milestone_number = context.payload.milestone.number;
const milestone_title = context.payload.milestone.title;
// Get all issues associated with the milestone
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
milestone: milestone_number,
state: 'all',
});
// Find the closed milestone that matches the title
const closedMilestone = milestones.data.find(milestone => milestone.title === milestone_title && milestone.state === 'closed');
if (closedMilestone) {
// Post a comment on the issue
// Loop through the issues and post a comment on each one
for (const issue of issues.data) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
issue_number: issue.number,
body: `This issue has been resolved in Activity Browser [version ${milestone_title}](https://github.com/LCA-ActivityBrowser/activity-browser/releases/tag/${milestone_title}), please [update Activity Browser](https://github.com/LCA-ActivityBrowser/activity-browser#updating-the-ab).`,
});
}