Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
hiento09 committed Mar 27, 2024
1 parent 9a324f4 commit a111b7c
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions .github/workflows/auto-assign-milestone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
runs-on: ubuntu-latest
permissions:
pull-requests: write
issues: write # Cần thêm quyền ghi issues để cập nhật milestone
steps:
- name: Assign Milestone
uses: actions/github-script@v3
Expand All @@ -17,32 +18,27 @@ jobs:
script: |
const { owner, repo } = context.repo;
const { number, merged } = context.payload.pull_request;
if (merged) {
if (true) {
const { data: milestones } = await github.issues.listMilestones({
owner,
repo,
state: 'open',
});
const closedPR = await github.pulls.get({
owner,
repo,
pull_number: number,
});
const closedDate = new Date(closedPR.data.closed_at);
const mergedDate = new Date(context.payload.pull_request.merged_at);
const currentMilestone = milestones.find((milestone) => {
const dueDate = new Date(milestone.due_on);
return closedDate <= dueDate;
return mergedDate <= dueDate;
});
if (currentMilestone) {
await github.issues.addLabels({
await github.issues.update({
owner,
repo,
issue_number: number,
labels: [currentMilestone.title],
milestone: currentMilestone.number
});
}
}
debug: true

0 comments on commit a111b7c

Please sign in to comment.