-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (111 loc) · 4.92 KB
/
item-labeled.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
100
101
102
103
104
105
106
107
108
109
110
111
112
# Copyright Broadcom, Inc. All Rights Reserved.
# SPDX-License-Identifier: APACHE-2.0
# This workflow is built to manage the triage support by using GH issues.
name: '[Support] Reasign tasks'
on:
workflow_call:
secrets:
BITNAMI_SUPPORT_BOARD_TOKEN:
required: true
# Remove all permissions by default
permissions: {}
jobs:
get-info:
name: Get labels info
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
label-mapping: ${{ steps.get-info.outputs.label-mapping }}
label-keys: ${{ steps.get-info.outputs.label-keys }}
assignable-label-keys: ${{ steps.get-info.outputs.assignable-label-keys }}
author: ${{ steps.get-info.outputs.author }}
assignees: ${{ steps.get-info.outputs.assignees }}
steps:
- name: Repo checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 1
repository: bitnami/support
- name: Load .env file
uses: xom9ikk/dotenv@ac290ca23a42155a0cba1031d23afa46240116a9
- id: get-info
name: Get label mapping
env:
GITHUB_TOKEN: ${{ secrets.BITNAMI_SUPPORT_BOARD_TOKEN }}
run: |
author="${{ github.event.issue != null && github.event.issue.user.login || github.event.pull_request.user.login }}"
repo_name="${{ github.event.repository.name }}"
group="${{github.event.label.name == 'triage' && 'triage' || 'support' }}"
assignment=$(echo "$REPO_ASSIGNMENT" | jq -cr ".\"${repo_name}\" // .default")
assignment_team=$(echo "$assignment" | jq -cr ".\"${group}-teams\" // empty")
assignees=$(echo "$assignment" | jq -cr ".\"${group}-assignees\" // empty")
# If there is no assignees and the team is not empty
if [[ -n "$assignment_team" ]] && [[ -z "$assignees" ]]; then
assignees=$(gh api "/orgs/bitnami/teams/${assignment_team}/members" |jq -cr 'sort_by(.login)|map(.login)|join(",")')
fi
label_keys=$(echo "$LABEL_MAPPING" | jq -cr 'keys')
assignable_label_keys=$(echo "$LABEL_MAPPING" | jq -cr '[to_entries[] | select(.value."assign-to-team-member"==true) | .key]')
echo "author=${author}" >> $GITHUB_OUTPUT
echo "label-keys=${label_keys}" >> $GITHUB_OUTPUT
echo "assignable-label-keys=${assignable_label_keys}" >> $GITHUB_OUTPUT
echo "label-mapping=${LABEL_MAPPING}" >> $GITHUB_OUTPUT
echo "assignees=${assignees}" >> $GITHUB_OUTPUT
# For any opened or reopened issue, should be sent into Triage
send_to_board:
name: Move card
runs-on: ubuntu-latest
needs: get-info
if : |
github.event.action == 'labeled' && github.actor != 'bitnami-bot' &&
contains(fromJson(needs.get-info.outputs.label-keys),github.event.label.name)
steps:
- name: Add to board
id: add-to-project
uses: actions/add-to-project@244f685bbc3b7adfa8466e08b698b5577571133e
with:
# Support project
project-url: https://github.com/orgs/bitnami/projects/4
github-token: ${{ secrets.BITNAMI_SUPPORT_BOARD_TOKEN }}
- name: Add to column
uses: EndBug/project-fields@6f7fc6da0386e32a70b25a766c6c01aef52c7d6b
with:
project_url: https://github.com/orgs/bitnami/projects/4
github_token: ${{ secrets.BITNAMI_SUPPORT_BOARD_TOKEN }}
operation: set
fields: Status
values: ${{ fromJson(needs.get-info.outputs.label-mapping)[github.event.label.name].column }}
assign:
name: Assign if needed
runs-on: ubuntu-latest
needs: get-info
permissions:
pull-requests: write
issues: write
if : |
github.event.action == 'labeled' && github.actor != 'bitnami-bot' &&
contains(fromJson(needs.get-info.outputs.assignable-label-keys),github.event.label.name)
steps:
- name: Assign issue/PR
uses: pozil/auto-assign-issue@b787bcda4fa1620522e73e7a5fe0f3b57b03b6ad
with:
numOfAssignee: 1
removePreviousAssignees: ${{ fromJson(needs.get-info.outputs.label-mapping)[github.event.label.name].remove-previous-assignees }}
assignees: ${{ needs.get-info.outputs.assignees }}
# If we have repos with only one assignees we allow selfAssignment
allowSelfAssign: ${{ needs.get-info.outputs.assignees == needs.get-info.outputs.author }}
remove-labels:
name: Remove previous labels
runs-on: ubuntu-latest
needs: get-info
permissions:
pull-requests: write
issues: write
if : |
github.event.action == 'labeled' && github.actor != 'bitnami-bot' &&
contains(fromJson(needs.get-info.outputs.label-keys),github.event.label.name)
steps:
- name: Remove innecesary tags
uses: fmulero/labeler@f49bf680252fc8ac12cbebb6e0ed8ea19d0712da
with:
remove-labels: ${{ join(fromJson(needs.get-info.outputs.label-mapping)[github.event.label.name].labels-to-remove, ',') }}