Bukama commented on code in PR #221:
URL:
https://github.com/apache/maven-gh-actions-shared/pull/221#discussion_r2554678226
##########
.github/workflows/release-drafter.yml:
##########
@@ -98,3 +102,87 @@ jobs:
- name: Verify release drafter status
if: steps.release-drafter.outputs.id == ''
run: exit 1
+
+ milestones-managment:
+ name: Milestones Management
+ needs: detect-version
+ permissions:
+ # write permission is required to manage milestones
+ issues: write
+ runs-on: ubuntu-latest
+ # execute only on next development commits
+ if: >
+ needs.detect-version.outputs.version != '' &&
+ startsWith(github.event.head_commit.message , '[maven-release-plugin]
prepare for next development iteration')
+
+ steps:
+ - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd #
v8.0.0
+ env:
+ CURRENT_VERSION: ${{ needs.detect-version.outputs.version }}
+ with:
+ script: |
+ const branch = context.ref.replace('refs/heads/', '');
+ const version = process.env.CURRENT_VERSION;
+
+ console.log('branch: ' + branch);
+ console.log('version: ' + version);
+
+ const milestones = await github.rest.issues.listMilestones({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ state: 'open'
+ });
+
+ console.log('All open milestones: ');
+ console.log(milestones.data);
+
+ var milestone;
+ if (milestones.data.length > 1) {
+ milestone = milestones.data.find(({description}) =>
description?.includes('branch: ' + branch));
+ } else {
+ milestone = milestones.data[0];
+ }
+
+ console.log('Current milestone: ');
+ console.log(milestone);
+
+ core.summary.addHeading('Milestone management');
+
+ // in first step just create new milestone - closing the old one
will be in the next step
+ // if something fails here - we don't want to close the existing
milestone
+ const resultNew = await github.rest.issues.createMilestone({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ title: version,
+ description: 'branch: ' + branch
+ });
+
+ console.log('Created new milestone: ');
+ console.log(resultNew.data);
+
+ core.summary.addRaw('New milestone: ');
+ core.summary.addLink(resultNew.data.title,
resultNew.data.html_url);
+ core.summary.addBreak();
+
+ // now close the existing milestone
+ if (milestone) {
+ const resultOld = await github.rest.issues.updateMilestone({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ milestone_number: milestone.number,
+ state: 'closed'
+ });
+
+ console.log('Closed old milestone: ');
+ console.log(resultOld.data);
+
+ core.summary.addRaw('Closed milestone: ');
+ core.summary.addLink(milestone.title, milestone.html_url);
+ core.summary.addBreak();
+ } else {
+ console.log('No existing milestone to close');
+ core.summary.addRaw('No existing milestone to close - plese
verify');
Review Comment:
please
##########
.github/workflows/release-drafter.yml:
##########
@@ -98,3 +102,87 @@ jobs:
- name: Verify release drafter status
if: steps.release-drafter.outputs.id == ''
run: exit 1
+
+ milestones-managment:
+ name: Milestones Management
+ needs: detect-version
+ permissions:
+ # write permission is required to manage milestones
+ issues: write
+ runs-on: ubuntu-latest
+ # execute only on next development commits
+ if: >
+ needs.detect-version.outputs.version != '' &&
+ startsWith(github.event.head_commit.message , '[maven-release-plugin]
prepare for next development iteration')
+
+ steps:
+ - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd #
v8.0.0
+ env:
+ CURRENT_VERSION: ${{ needs.detect-version.outputs.version }}
+ with:
+ script: |
+ const branch = context.ref.replace('refs/heads/', '');
+ const version = process.env.CURRENT_VERSION;
+
+ console.log('branch: ' + branch);
+ console.log('version: ' + version);
+
+ const milestones = await github.rest.issues.listMilestones({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ state: 'open'
+ });
+
+ console.log('All open milestones: ');
+ console.log(milestones.data);
+
+ var milestone;
+ if (milestones.data.length > 1) {
+ milestone = milestones.data.find(({description}) =>
description?.includes('branch: ' + branch));
+ } else {
+ milestone = milestones.data[0];
Review Comment:
We have repositories with two milestones without descriptions, e.g. a
`1.2.2` and a `1.3.0` milestones. I'm not sure which would be picked here.
(And yes this should not be / handled by having a 1.2.x branch and branch
name in milestone and the 1.3.0-SNAPSHOT on master with master in name.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]