Release Schedule #9
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: Release Schedule | |
on: | |
# schedule: | |
# - cron: '0 0 * * MON' | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch }} | |
cancel-in-progress: true | |
jobs: | |
create-issue: | |
runs-on: ubuntu-latest | |
if: ${{ github.repository == 'joshblack/actions-release-rotation' }} | |
permissions: | |
issues: write | |
steps: | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Install packages for github-script | |
run: npm i date-fns | |
- name: Create Release Issue | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const startOfWeek = require('date-fns/startOfWeek'); | |
const nextFriday = require('date-fns/nextFriday'); | |
const format = require('date-fns/format'); | |
const today = new Date(); | |
const start = startOfWeek(today, { weekStartsOn: 1 }); | |
const end = nextFriday(start); | |
const ISSUE_TITLE = 'Release Tracking' | |
const ISSUE_BODY = [ | |
`_This is a weekly scheduled issue for release tracking between ${format(start, 'EEEE do')} and ${format(end, 'EEEE do')}_`, | |
'## Checklist', | |
'', | |
'- [ ] Item one', | |
'- [ ] Item two', | |
'', | |
'## Timeline', | |
'<!-- Provide updates for release activities, like cutting releases and different integration points -->', | |
'', | |
'## Challenges', | |
'<!-- Provide information about release issues that came up during this cycle', | |
].join('\n'); | |
const iterator = github.paginate.iterator( | |
github.rest.issues.listForRepo, | |
{ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
state: 'open', | |
per_page: 100, | |
} | |
); | |
let currentReleaseIssue = null; | |
for await (const page of iterator) { | |
currentReleaseIssue = page.data.find((issue) => { | |
return issue.title === ISSUE_TITLE; | |
}); | |
if (currentReleaseIssue) { | |
break; | |
} | |
} | |
if (currentReleaseIssue) { | |
github.rest.issues.update({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: currentReleaseIssue.number, | |
state: 'closed', | |
state_reason: 'completed', | |
}); | |
} | |
await github.rest.issues.create({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
title: ISSUE_TITLE, | |
body: ISSUE_BODY, | |
}); |