diff --git a/.github/workflows/infra-meeting-release.yaml b/.github/workflows/infra-meeting-release.yaml new file mode 100644 index 0000000..e4c6b51 --- /dev/null +++ b/.github/workflows/infra-meeting-release.yaml @@ -0,0 +1,117 @@ +name: "Prepare infra meeting notes as release" + +on: + workflow_dispatch: + inputs: + milestone_id: + description: '"Current" milestone id to prepare as release' + required: true + type: string + milestone_name: + description: '"Current" milestone name' + required: true + default: 'current' + type: string + next_milestone_id: + description: '"Next" milestone id' + required: true + # "permanent" 'next' milestone: https://github.com/jenkins-infra/helpdesk/milestone/10 + default: '10' + type: string + next_milestone_name: + description: '"Next" milestone name' + required: true + default: 'next' + type: string + +jobs: + release: + name: "Prepare infra meeting notes as release" + runs-on: "ubuntu-latest" + steps: + - name: "Get current date" + id: date + run: echo "::set-output name=date::$(date +'%Y-%m-%d')" + + - name: "Generate markdown from current and next milestone" + id: milestones_as_markdown + uses: "actions/github-script@v6" + with: + result-encoding: string + script: | + const getMilestoneAsMarkdown = async function(milestone, milestoneName, issuesState) { + const opts = github.rest.issues.listForRepo.endpoint.merge({ + ...context.issue, + milestone, + state: issuesState + }) + const issues = await github.paginate(opts) + + let markdown = '' + let category = 'Done' + + // There should not be any closed issue in the 'next' milestone, only 'Done' ones + if (issuesState != 'closed') { + category = (milestoneName != 'next') ? 'Work In Progress' : 'New/Important' + } + + if (issues.length > 0) { + markdown = `* [${category}](${context.payload.repository.html_url}/milestone/${milestone}?closed=1):` + for (const issue of issues) { + markdown = markdown.concat("\r\n").concat(` * [${issue.title}](${issue.html_url})`) + } + } + + return markdown + } + + done = await getMilestoneAsMarkdown(context.payload.inputs.milestone_id, context.payload.inputs.milestone_name, 'open') + wip = await getMilestoneAsMarkdown(context.payload.inputs.milestone_id, context.payload.inputs.milestone_name, 'closed') + next = await getMilestoneAsMarkdown(context.payload.inputs.next_milestone_id, context.payload.inputs.next_milestone_name, 'open') + + return `Markdown for the infra team sync meeting notes preparation: +
+ ${done} + + ${wip} + + ${next} ++ +