1
0
This commit is contained in:
Stephan 2022-01-10 20:00:34 +01:00
parent e0f2b0031a
commit eb36d5f680

View File

@ -53,7 +53,7 @@ module.exports = async ({github, context, core}) => {
// get and validate the event action // get and validate the event action
const eventAction = context.payload.action const eventAction = context.payload.action
if (false && eventAction != 'created' && eventAction != 'deleted') { if (eventAction != 'created' && eventAction != 'deleted') {
return return
} }
@ -72,16 +72,18 @@ module.exports = async ({github, context, core}) => {
}); });
const project = projectResponse.data const project = projectResponse.data
console.log(project) console.log(project)
const projectName = project.name // this! is the project name, we want a milestone with the same name const projectName = project.name
const cardId = context.payload.project_card.id // -- when a card is deleted it cannot be fetched!
const cardResponse = await restapi.projects.getCard({ //const cardId = context.payload.project_card.id
card_id: cardId //const cardResponse = await restapi.projects.getCard({
}) // card_id: cardId
const card = cardResponse.data //})
console.log(card) //const card = cardResponse.data
//console.log(card)
const [ itemType, itemNumber ] = last2(card.content_url) //const [ itemType, itemNumber ] = last2(card.content_url)
const [ itemType, itemNumber ] = last2(context.payload.project_card.content_url)
const isIssue = itemType == 'issues' const isIssue = itemType == 'issues'
const isPull = itemType == 'pulls' const isPull = itemType == 'pulls'
if (!isIssue && !isPull) { if (!isIssue && !isPull) {
@ -125,16 +127,18 @@ module.exports = async ({github, context, core}) => {
milestone = milestoneResponse.data milestone = milestoneResponse.data
} }
const milestoneId = milestone.id
const milestoneNumber = milestone.number const milestoneNumber = milestone.number
request = { if (!item.milestone || item.milestone.number != milestoneNumber)
owner: context.repo.owner, {
repo: context.repo.repo, request = {
milestone: milestoneNumber owner: context.repo.owner,
repo: context.repo.repo,
milestone: milestoneNumber
}
request[isIssue ? 'issue_number' : 'pull_number'] = itemNumber
await itemApi.update(request)
} }
request[isIssue ? 'issue_number' : 'pull_number'] = itemNumber
await itemApi.update(request)
} }
else if (eventAction == 'deleted') { else if (eventAction == 'deleted') {
if (itemMilestone) { if (itemMilestone) {