Skip to content

Commit 6cbdbb0

Browse files
committed
Added stat:reply-needed label handling
1 parent b2f53fd commit 6cbdbb0

File tree

3 files changed

+53
-38
lines changed

3 files changed

+53
-38
lines changed

.github/workflows/autolabel.yaml renamed to .github/workflows/conversation-labels.yaml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
name: Update issue labels
1+
# This workflow will update issues with proper "conversation related" labels. This mean that stat:awaiting-repsonse label will be present after Unity account made comments and stat:reply-needed will be present when user made latest comment
2+
3+
name: Update conversation labels of the issue
24

35
# Trigger for the workflow
46
# This trigger will populate the github.event object
@@ -13,11 +15,12 @@ concurrency:
1315

1416
# Define labels here
1517
env:
16-
AWAITING_RESPONSE: stat:awaiting response
18+
AWAITING_RESPONSE: stat:awaiting-response
19+
REPLY_NEEDED: stat:reply-needed
1720

1821
jobs:
19-
auto_label:
20-
name: Calculate and update issue labels
22+
conversation_labels:
23+
name: Calculate and update conversation labels of the issue
2124
if: ${{ !github.event.issue.pull_request }} && ${{ github.event.issue.state == 'open' }}
2225
runs-on: ubuntu-latest
2326
permissions:
@@ -28,9 +31,13 @@ jobs:
2831
run: |
2932
3033
if [[ "${{ github.event.comment.author_association }}" == "MEMBER" ]]; then
31-
echo ADD="${{ env.AWAITING_RESPONSE}}" >> $GITHUB_ENV
34+
# Unity member commented - add awaiting-response, remove reply-needed
35+
echo "ADD=${{ env.AWAITING_RESPONSE }}" >> $GITHUB_ENV
36+
echo "REMOVE=${{ env.REPLY_NEEDED }}" >> $GITHUB_ENV
3237
else
33-
echo REMOVE="${{ env.AWAITING_RESPONSE}}" >> $GITHUB_ENV
38+
# Non-Unity member commented - add reply-needed, remove awaiting-response
39+
echo "ADD=${{ env.REPLY_NEEDED }}" >> $GITHUB_ENV
40+
echo "REMOVE=${{ env.AWAITING_RESPONSE }}" >> $GITHUB_ENV
3441
fi
3542
3643
- name: Update labels
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This workflow will remove almost all labels from closed issues beside ones that could be relevant for future tracking like: "port:", "type:", "priority:" and "regression"
2+
3+
name: Remove labels when issue is closed
4+
5+
on:
6+
issues:
7+
types: [closed] # We want it to run on closed issues
8+
9+
jobs:
10+
remove_labels:
11+
name: Calculate and remove issue labels
12+
if: ${{ !github.event.issue.pull_request }} # This is needed to distinguish from PRs (which we don't want to affect)
13+
runs-on: ubuntu-latest
14+
permissions:
15+
issues: write
16+
17+
steps:
18+
- name: Find labels to remove
19+
id: data
20+
run: |
21+
# Convert labels to array and filter out type: labels
22+
LABELS_TO_REMOVE=($(echo "$EXISTING_LABELS" | jq -r '.[] | select(startswith("type:") or startswith("port:") or startswith("priority:") or . == "regression" | not)'))
23+
24+
# Only proceed if we have labels to remove
25+
if [ ${#LABELS_TO_REMOVE[@]} -gt 0 ]; then
26+
echo "REMOVE_LABELS=$(IFS=,; echo "${LABELS_TO_REMOVE[*]}")" >> $GITHUB_ENV
27+
echo "HAS_LABELS=true" >> $GITHUB_ENV
28+
else
29+
echo "HAS_LABELS=false" >> $GITHUB_ENV
30+
fi
31+
env:
32+
EXISTING_LABELS: ${{ toJson(github.event.issue.labels.*.name) }}
33+
34+
- name: Remove labels
35+
if: env.HAS_LABELS == 'true'
36+
run: gh issue edit "$NUMBER" --remove-label "$REMOVE_LABELS"
37+
env:
38+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
GH_REPO: ${{ github.repository }}
40+
NUMBER: ${{ github.event.issue.number }}

.github/workflows/removel-labels-on-issue-close.yaml

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)