Skip to content

Instantly share code, notes, and snippets.

@takayukioda
Created June 19, 2019 02:29
Show Gist options
  • Select an option

  • Save takayukioda/6a0cb9fbc62948abe3ba0652860b79f1 to your computer and use it in GitHub Desktop.

Select an option

Save takayukioda/6a0cb9fbc62948abe3ba0652860b79f1 to your computer and use it in GitHub Desktop.
const Octokit = require('@octokit/rest')
const { addDays, format, isBefore } = require('date-fns')
const octokit = Octokit({
auth: process.env.GITHUB_TOKEN,
baseUrl: 'https://api.github.com',
})
const stopAt = new Date('2019-11-30Z')
let nextSprint = {
id: 13,
due: new Date('2019-06-28T19:00:00+09:00'),
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
(async () => {
while (isBefore(nextSprint.due, stopAt)) {
console.log(`Create milestone: Sprint ${nextSprint.id}`)
await sleep(500)
await octokit.issues.createMilestone({
owner: 'givery-technology',
repo: 'athletics-backend',
title: `Sprint ${nextSprint.id}`,
due_on: format(nextSprint.due, 'YYYY-MM-DDTHH:mm:ssZ'),
})
nextSprint = {
id: nextSprint.id + 1,
due: addDays(nextSprint.due, 7),
}
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment