Prepare infra meeting notes as release #158
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
jobs: | |
release: | |
name: "Prepare infra meeting notes as release" | |
runs-on: "ubuntu-latest" | |
steps: | |
- name: "Get current date" | |
id: date | |
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
- name: "Generate markdown from current milestone" | |
id: milestones_as_markdown | |
uses: actions/github-script@v7 | |
with: | |
result-encoding: string | |
script: | | |
const getMilestoneAsMarkdown = async function(milestone, issuesState, closeReason, labels) { | |
const opts = github.rest.issues.listForRepo.endpoint.merge({ | |
...context.issue, | |
milestone, | |
state: issuesState, | |
sort: 'created', | |
direction: 'desc', | |
per_page: 100, | |
labels: labels, | |
}) | |
const issues = await github.paginate(opts) | |
let markdown = '' | |
let category = '' | |
let query = '' | |
if (issuesState == 'open') { | |
if (labels == 'triage') { | |
category = 'New Issues (to triage)' | |
} else { | |
category = 'Work in Progress' | |
} | |
} else { | |
// issues states can only be 'closed' if not 'open' | |
query = '?closed=1' | |
if (closeReason == 'completed') { | |
category = 'Done' | |
} else { | |
// Close reason can only be "Not planned" if not "Completed" | |
category = 'Closed as not planned' | |
} | |
} | |
title = `* [${category}](${context.payload.repository.html_url}/milestone/${milestone}${query}):` | |
if (issues.length > 0) { | |
for (const issue of issues) { | |
if ((issuesState == 'open') || ((issuesState == 'closed') && (issue.state_reason == closeReason))){ | |
markdown = markdown.concat("\r\n").concat(` * [${issue.title}](${issue.html_url})`) | |
} | |
} | |
} | |
if (markdown != '') markdown = title.concat("\r\n").concat(markdown) | |
return markdown | |
} | |
let done = await getMilestoneAsMarkdown(context.payload.inputs.milestone_id, 'closed', 'completed', '') | |
let notPlanned = await getMilestoneAsMarkdown(context.payload.inputs.milestone_id, 'closed', 'not_planned', '') | |
let wip = await getMilestoneAsMarkdown(context.payload.inputs.milestone_id, 'open', '', '') | |
let todo = await getMilestoneAsMarkdown('none', 'open', '', 'triage') | |
return `Markdown for the infra team sync meeting notes preparation: | |
<pre><code> | |
${done} | |
${notPlanned} | |
${wip} | |
${todo} | |
</code></pre> | |
` | |
- name: "Create release" | |
id: create_release | |
uses: actions/github-script@v7 | |
env: | |
CURRENT_DATE: ${{ steps.date.outputs.date }} | |
RELEASE_BODY: ${{steps.milestones_as_markdown.outputs.result}} | |
with: | |
script: | | |
name = `infra-team-sync-${process.env.CURRENT_DATE}` | |
tag = `${name}_${context.runNumber}` | |
try { | |
await github.rest.repos.createRelease({ | |
name: name, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: process.env.RELEASE_BODY, | |
tag_name: tag, | |
draft: true, | |
generate_release_notes: true, | |
prerelease: false, | |
}); | |
} catch (error) { | |
core.setFailed(error.message); | |
} |