fix: thread error handling #729
Workflow file for this run
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
# Pipeline auto assign current milestone for PR after the PR is merge | |
name: Assign Milestone | |
on: | |
pull_request: | |
types: [closed] | |
jobs: | |
assign_milestone: | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: write | |
issues: write | |
steps: | |
- name: Assign Milestone | |
uses: actions/github-script@v3 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const { owner, repo } = context.repo; | |
const { number, merged } = context.payload.pull_request; | |
if (merged) { | |
const { data: milestones } = await github.issues.listMilestones({ | |
owner, | |
repo, | |
state: 'open', | |
}); | |
const mergedDate = new Date(context.payload.pull_request.merged_at); | |
const currentMilestone = milestones | |
.filter(milestone => milestone.due_on !== null) | |
.find((milestone) => { | |
const dueDate = new Date(milestone.due_on); | |
return mergedDate <= dueDate; | |
}); | |
if (currentMilestone) { | |
await github.issues.update({ | |
owner, | |
repo, | |
issue_number: number, | |
milestone: currentMilestone.number | |
}); | |
} | |
} | |
debug: true | |