-
Notifications
You must be signed in to change notification settings - Fork 481
99 lines (90 loc) · 3.92 KB
/
project-management.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Project management
on:
issues:
types: [ closed ]
pull_request:
types: [ review_requested ]
jobs:
not_planned_issue:
name: Update task for not planned issue
if: ${{ github.event.issue && github.event.action == 'closed' && github.event.issue.state_reason == 'not_planned' }}
uses: './.github/workflows/update-project-cards.yml'
with:
project_name: ${{ vars.PROJECT_NAME }}
field_name: Status
field_value: Done
issues: "[${{ github.event.issue.number }}]"
secrets: inherit
completed_issue:
name: Update task for completed issue
if: ${{ github.event.issue && github.event.action == 'closed' && github.event.issue.state_reason == 'completed' }}
uses: './.github/workflows/update-project-cards.yml'
with:
project_name: ${{ vars.PROJECT_NAME }}
field_name: Status
field_value: Ready For Realease
issues: "[${{ github.event.issue.number }}]"
secrets: inherit
pr_linked_issues:
name: Get issues linked to PR
runs-on: ubuntu-latest
if: ${{ github.event.pull_request && github.event.action == 'review_requested' }}
outputs:
issues: ${{ steps.linked_issues.outputs.result }}
steps:
- name: Fetching issues linked to pull request
id: linked_issues
uses: actions/github-script@v7
env:
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
with:
script: |
const response = await github.graphql(`
query ($owner: String!, $repo: String!, $pr: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $pr) {
number
title
closingIssuesReferences(first: 100) {
nodes {
number
title
closed
}
}
}
}
}
`, {
owner: context.repo.owner,
repo: context.repo.repo,
pr: Number(process.env.PULL_REQUEST_NUMBER),
});
const { repository: { pullRequest: { closingIssuesReferences } } } = response;
const issues = closingIssuesReferences.nodes.map(({ number }) => number);
if (!issues.length) {
core.notice(`No linked issues found for pull request #${ process.env.PULL_REQUEST_NUMBER }`);
return;
}
core.info(`Found ${ issues.length } issue(s): ${ issues.join(', ') || '-' }`);
return issues;
issues_in_review:
name: Update status for issues in review
needs: [ pr_linked_issues ]
if: ${{ needs.pr_linked_issues.outputs.issues }}
uses: './.github/workflows/update-project-cards.yml'
secrets: inherit
with:
project_name: ${{ vars.PROJECT_NAME }}
field_name: Status
field_value: Review
issues: ${{ needs.pr_linked_issues.outputs.issues }}
copy_labels:
name: Copy issues labels to pull request
needs: [ pr_linked_issues ]
if: ${{ needs.pr_linked_issues.outputs.issues }}
uses: './.github/workflows/copy-issues-labels.yml'
secrets: inherit
with:
pr_number: ${{ github.event.pull_request.number }}
issues: ${{ needs.pr_linked_issues.outputs.issues }}