Skip to content

Commit 7615dd3

Browse files
authored
Add Issue Assignment workflow (#169)
Resolves #166 Adds a new GitHub workflow that runs when an issue is assigned. While additional behavior can be added in the future, right now the workflow only removes the `state:needs-owner` label if present. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
1 parent f8b8d64 commit 7615dd3

4 files changed

Lines changed: 84 additions & 0 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# This reusable workflow provides actions that should be applied when an issue is assigned.
2+
#
3+
# NOTE: This file uses a reusable workflow. Do not make changes to the file that should be made
4+
# in the common/reusable workflow.
5+
#
6+
# Copyright (c) Microsoft Corporation.
7+
# SPDX-License-Identifier: BSD-2-Clause-Patent
8+
9+
name: React to Issue Assignment
10+
11+
on:
12+
workflow_call:
13+
14+
jobs:
15+
adjust-labels:
16+
name: Adjust Issue Labels
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
21+
- name: Remove Labels
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
run: |
25+
# All labels here will be removed if present in the issue
26+
LABELS_TO_REMOVE=("state:needs-owner")
27+
28+
# Gather issue context information
29+
ISSUE_NUMBER=$(jq --raw-output .issue.number "$GITHUB_EVENT_PATH")
30+
OWNER=$(jq --raw-output .repository.owner.login "$GITHUB_EVENT_PATH")
31+
REPO=$(jq --raw-output .repository.name "$GITHUB_EVENT_PATH")
32+
LABELS=$(curl -s \
33+
-H "Accept: application/vnd.github+json" \
34+
-H "Authorization: Bearer $GITHUB_TOKEN" \
35+
-H "X-GitHub-Api-Version: 2022-11-28" \
36+
https://api.github.com/repos/$OWNER/$REPO/issues/$ISSUE_NUMBER/labels | jq -r '.[].name')
37+
38+
# Remove labels
39+
for LABEL in "${LABELS_TO_REMOVE[@]}"; do
40+
if echo "$LABELS" | grep -q "$LABEL"; then
41+
curl -X DELETE \
42+
-s \
43+
-H "Accept: application/vnd.github+json" \
44+
-H "Authorization: Bearer $GITHUB_TOKEN" \
45+
-H "X-GitHub-Api-Version: 2022-11-28" \
46+
https://api.github.com/repos/$OWNER/$REPO/issues/$ISSUE_NUMBER/labels/"$LABEL" > /dev/null
47+
echo "$LABEL removed from issue #$ISSUE_NUMBER"
48+
else
49+
echo "$LABEL not found on issue #$ISSUE_NUMBER"
50+
fi
51+
done

.sync/Files.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,10 @@ group:
379379
microsoft/mu_tiano_plus
380380
381381
# Leaf Workflow - Issue Triage
382+
# Leaf Workflow - Issue Assignment
383+
# Note: This workflow is synced with "Issue Triage" because it adjusts
384+
# labels typically applied in the triage process and applies to the
385+
# same set of repositories that support issue labeing.
382386
- files:
383387
- source: .sync/workflows/leaf/triage-issues.yml
384388
dest: .github/workflows/triage-issues.yml
@@ -388,6 +392,9 @@ group:
388392
# at `.github/workflows/triage-issues/issue-label-mapping.yml`.
389393
- source: .sync/workflows/config/triage-issues/advanced-issue-labeler.yml
390394
dest: .github/advanced-issue-labeler.yml
395+
- source: .sync/workflows/leaf/issue-assignment.yml
396+
dest: .github/workflows/issue-assignment.yml
397+
template: true
391398
repos: |
392399
microsoft/mu
393400
microsoft/mu_basecore
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This workflow provides actions that should be applied when an issue is assigned.
2+
#
3+
# NOTE: This file is automatically synchronized from Mu DevOps. Update the original file there
4+
# instead of the file in this repo.
5+
#
6+
# - Mu DevOps Repo: https://github.com/microsoft/mu_devops
7+
# - File Sync Settings: https://github.com/microsoft/mu_devops/blob/main/.sync/Files.yml
8+
#
9+
# Copyright (c) Microsoft Corporation.
10+
# SPDX-License-Identifier: BSD-2-Clause-Patent
11+
#
12+
13+
{% import '../../Version.njk' as sync_version -%}
14+
15+
name: React to Issue Assignment
16+
17+
on:
18+
issues:
19+
types: assigned
20+
21+
jobs:
22+
apply:
23+
uses: microsoft/mu_devops/.github/workflows/IssueAssignment.yml@{{ sync_version.mu_devops }}

ReadMe.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ workflow will run in the repo.
172172

173173
.. _`GitHub issue form templates`: https://github.com/microsoft/mu_devops/tree/main/.sync/github_templates/ISSUE_TEMPLATE
174174

175+
This workflow works in concert with other issue workflows such as `.sync/workflows/leaf/issue-assignment.yml` to
176+
automate labels in issues based on the state of the issue.
177+
175178
Auto Merge
176179
----------
177180

0 commit comments

Comments
 (0)