-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (101 loc) · 4.43 KB
/
add-to-project.yaml
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
100
101
102
# Copyright 2024 Zaphiro Technologies
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Project Management
on:
issues:
types:
- labeled
pull_request:
branches: [ main ]
types:
- labeled
- ready_for_review
workflow_call:
inputs:
labeled:
required: false
default: bug, ci, dependencies, documentation, feature, refactor, security, customer
type: string
project-url:
required: false
type: string
reviewers-team:
required: false
default: 'backend-devs'
type: string
reviewers-individuals:
required: false
type: string
jobs:
add-to-project:
name: Add issue/PR to a project
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/[email protected]
id: add-project
with:
# You can target a project in a different organization
# to the issue
project-url: ${{ inputs.project-url != '' && inputs.project-url || secrets.PLATFORM_PROJECT_URL }}
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
labeled: ${{ inputs.labeled }}
- if: ${{ github.event_name == 'pull_request' && github.event.pull_request.draft == true && steps.add-project.outputs.itemId }}
uses: titoportas/[email protected]
with:
project-url: ${{ inputs.project-url != '' && inputs.project-url || secrets.PLATFORM_PROJECT_URL }}
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
item-id: ${{ steps.add-project.outputs.itemId }} # Use the item-id output of the previous step
field-keys: Status
field-values: 🏗 In progress
- if: ${{ github.event_name == 'pull_request' && github.event.pull_request.draft == false && steps.add-project.outputs.itemId }}
uses: titoportas/[email protected]
with:
project-url: ${{ inputs.project-url != '' && inputs.project-url || secrets.PLATFORM_PROJECT_URL }}
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
item-id: ${{ steps.add-project.outputs.itemId }} # Use the item-id output of the previous step
field-keys: Status
field-values: 🔖 Ready
- name: Assign PR to creator
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.draft == false && steps.add-project.outputs.itemId }}
uses: thomaseizinger/[email protected]
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Add permissions
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.draft == false && steps.add-project.outputs.itemId }}
run: |
IFS=,
for TEAM in $TEAMS;
do
gh api \
--method PUT \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/orgs/$OWNER/teams/$TEAM/repos/$OWNER/$REPO \
-f permission='push'
done
env:
GITHUB_TOKEN: ${{ secrets.REPO_PAT }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
TEAMS: ${{ inputs.reviewers-team != '' && inputs.reviewers-team || 'backend-devs,ops' }}
- name: Add reviewers
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.draft == false && steps.add-project.outputs.itemId }}
uses: rowi1de/[email protected]
with:
repo-token: ${{ secrets.REPO_PAT }}
teams: ${{ inputs.reviewers-team != '' && inputs.reviewers-team || 'backend-devs,ops' }} # only works for GitHub Organisation/Teams
persons: ${{ inputs.reviewers-individuals }} # add individual persons here
include-draft: false # Draft PRs will be skipped (default: false)
skip-with-manual-reviewers: 1 # Skip this action, if the number of reviwers was already assigned (default: 0)