From a836d7c5d08fd371090c7f4c918397b12879e4e9 Mon Sep 17 00:00:00 2001 From: marc-vdm Date: Mon, 4 Dec 2023 20:38:25 +0100 Subject: [PATCH] GH action script for commenting on issues when related milestone is closed. --- .../workflows/comment-milestoned-issues.yaml | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/comment-milestoned-issues.yaml b/.github/workflows/comment-milestoned-issues.yaml index 5c4ab3c66..c8711bf53 100644 --- a/.github/workflows/comment-milestoned-issues.yaml +++ b/.github/workflows/comment-milestoned-issues.yaml @@ -1,7 +1,7 @@ name: Comment when milestone is closed on: - issues: - types: [milestoned] + milestone: + types: [closed] jobs: comment: @@ -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).`, }); } \ No newline at end of file