Repository navigation
60 lines (52 loc) · 2.38 KB
/
Copy pathIssueAssignment.yml
File metadata and controls
60 lines (52 loc) · 2.38 KB
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
# This reusable workflow provides actions that should be applied when an issue is assigned.
#
# NOTE: This file uses a reusable workflow. Do not make changes to the file that should be made
# in the common/reusable workflow.
#
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: BSD-2-Clause-Patent
name: React to Issue Assignment
on:
workflow_call:
jobs:
adjust-labels:
name: Adjust Issue Labels
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Generate Token
id: app-token
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
with:
app-id: ${{ vars.MU_ACCESS_APP_ID }}
private-key: ${{ secrets.MU_ACCESS_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Remove Labels
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
# All labels here will be removed if present in the issue
LABELS_TO_REMOVE=("state:needs-owner")
# Gather issue context information
ISSUE_NUMBER=$(jq --raw-output .issue.number "$GITHUB_EVENT_PATH")
OWNER=$(jq --raw-output .repository.owner.login "$GITHUB_EVENT_PATH")
REPO=$(jq --raw-output .repository.name "$GITHUB_EVENT_PATH")
LABELS=$(curl -s \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$OWNER/$REPO/issues/$ISSUE_NUMBER/labels | jq -r '.[].name')
# Remove labels
for LABEL in "${LABELS_TO_REMOVE[@]}"; do
if echo "$LABELS" | grep -q "$LABEL"; then
curl -X DELETE \
-s \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$OWNER/$REPO/issues/$ISSUE_NUMBER/labels/"$LABEL" > /dev/null
echo "$LABEL removed from issue #$ISSUE_NUMBER"
else
echo "$LABEL not found on issue #$ISSUE_NUMBER"
fi
done