Skip to content

chore: Add action to auto update labels on comments #3194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
df23afa
chore: Add action to auto update labels on comments
EmandM Jan 8, 2025
1d2828b
Merge branch 'develop' into chore/add_auto_labeler
NoelStephensUnity Jan 15, 2025
53ec291
Merge branch 'develop' into chore/add_auto_labeler
NoelStephensUnity Feb 5, 2025
0f0b3ab
Merge branch 'develop' of https://github.com/Unity-Technologies/com.u…
EmandM Mar 7, 2025
bbadb74
Update syntax, add on-close action
EmandM Mar 8, 2025
0cd6449
Merge branch 'develop' into chore/add_auto_labeler
EmandM Mar 10, 2025
07b603d
temp
EmandM Mar 12, 2025
b2f53fd
Merge branch 'develop' into chore/add_auto_labeler
NoelStephensUnity Mar 13, 2025
6cbdbb0
Added stat:reply-needed label handling
michalChrobot Mar 18, 2025
d3db9b6
Merge branch 'develop' into chore/add_auto_labeler
michalChrobot Mar 18, 2025
8c10d1d
Added workflow for marking stale issues
michalChrobot Mar 18, 2025
d304910
Added workflow for managing assigning and unassignig from an issue
michalChrobot Mar 18, 2025
8bfb5fc
Added possibility of an manual trigger
michalChrobot Mar 18, 2025
672ed1e
Merge branch 'chore/add_auto_labeler' of https://github.com/Unity-Tec…
michalChrobot Mar 18, 2025
eeaaae1
Added stat:import label to the list of exclusion when deleting labels…
michalChrobot Mar 18, 2025
2921422
Merge branch 'develop' into chore/add_auto_labeler
michalChrobot Mar 18, 2025
58550ef
Comments added and rfc template removed
michalChrobot Mar 18, 2025
e7e9ee9
Merge branch 'develop' into chore/add_auto_labeler
michalChrobot Mar 20, 2025
1c1960a
Merge branch 'develop' into chore/add_auto_labeler
EmandM Mar 31, 2025
2474f90
Merge branch 'develop' into chore/add_auto_labeler
michalChrobot Apr 1, 2025
c78d5b2
Added preimplemented stale GitHub action
michalChrobot Apr 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .github/ISSUE_TEMPLATE/rfc-tracking-issue.md

This file was deleted.

70 changes: 70 additions & 0 deletions .github/workflows/assignee-management.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# This workflow manages issue assignments and related label changes:
# 1. When someone is assigned to an issue:
# - Removes "stat:awaiting-triage" label
# - Adds "stat:Investigating" label
# 2. When all assignees are removed from an issue:
# - Adds "stat:awaiting-triage" label
# - Removes "stat:Investigating" label
# 3. When "stat:Investigating" label is added:
# - Automatically assigns the issue to the person who added the label

name: Handle Issue Assignment and Labels

on:
issues:
types: [assigned, unassigned, labeled]

env:
AWAITING-TRIAGE_LABEL: stat:awaiting-triage
INVESTIGATING_LABEL: stat:Investigating

jobs:
handle_assignment:
name: Handle Issue Assignment Changes
if: ${{ !github.event.issue.pull_request }} && ${{ github.event.issue.state == 'open' }}
runs-on: ubuntu-latest
permissions:
issues: write

steps:
- name: Handle Assignment Changes
run: |
if [[ "${{ github.event.action }}" == "assigned" ]]; then
# Someone was assigned - remove awaiting-triage, add investigating
echo "ADD=${{ env.INVESTIGATING_LABEL }}" >> $GITHUB_ENV
echo "REMOVE=${{ env.AWAITING-TRIAGE_LABEL }}" >> $GITHUB_ENV
elif [[ "${{ github.event.action }}" == "unassigned" ]]; then
# Check if there are any remaining assignees
ASSIGNEES=$(echo '${{ toJson(github.event.issue.assignees) }}' | jq length)
if [[ "$ASSIGNEES" == "0" ]]; then
# No assignees left - add awaiting-triage, remove investigating
echo "ADD=${{ env.AWAITING-TRIAGE_LABEL }}" >> $GITHUB_ENV
echo "REMOVE=${{ env.INVESTIGATING_LABEL }}" >> $GITHUB_ENV
fi
fi

- name: Update Labels
if: env.ADD != '' || env.REMOVE != ''
run: gh issue edit "$NUMBER" --add-label "$ADD" --remove-label "$REMOVE"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.issue.number }}

handle_investigating_label:
name: Handle Investigating Label Addition
if: ${{ github.event.action == 'labeled' && github.event.label.name == 'stat:Investigating' && !github.event.issue.pull_request && github.event.issue.state == 'open' }}
runs-on: ubuntu-latest
permissions:
issues: write

steps:
- name: Assign Issue to person that added Investigating Label
run: |
# Assign the issue to the person who added the label
gh issue edit "$NUMBER" --add-assignee "$ACTOR"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.issue.number }}
ACTOR: ${{ github.actor }}
51 changes: 51 additions & 0 deletions .github/workflows/conversation-labels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# 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

name: Update conversation labels of the issue

# Trigger for the workflow
# This trigger will populate the github.event object
# Details on properties are here: https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=created#issue_comment
on:
issue_comment:
types: [created]

concurrency:
group: ${{ github.workflow }}-${{ github.event.issue.number }}
cancel-in-progress: true

# Define labels here
env:
AWAITING_RESPONSE: stat:awaiting-response
REPLY_NEEDED: stat:reply-needed

jobs:
conversation_labels:
name: Calculate and update conversation labels of the issue
if: ${{ !github.event.issue.pull_request }} && ${{ github.event.issue.state == 'open' }}
runs-on: ubuntu-latest
permissions:
issues: write

steps:
- name: Calculate labels
run: |

if [[ "${{ github.event.comment.author_association }}" == "MEMBER" ]]; then
# Unity member commented - add awaiting-response, remove reply-needed
echo "ADD=${{ env.AWAITING_RESPONSE }}" >> $GITHUB_ENV
echo "REMOVE=${{ env.REPLY_NEEDED }}" >> $GITHUB_ENV
else
# Non-Unity member commented - add reply-needed, remove awaiting-response
echo "ADD=${{ env.REPLY_NEEDED }}" >> $GITHUB_ENV
echo "REMOVE=${{ env.AWAITING_RESPONSE }}" >> $GITHUB_ENV
fi

- name: Update labels
# This runs a command using the github cli: https://cli.github.com/manual/gh_issue_edit
# If $ADD is set, it will add the label, otherwise it will remove the label
# There is no need to check if $ADD or $REMOVE is set, as the command will ignore it if it is empty
run: gh issue edit "$NUMBER" --add-label "$ADD" --remove-label "$REMOVE"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.issue.number }}
38 changes: 38 additions & 0 deletions .github/workflows/mark-stale-issue.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This workflow utilises an existing implementation (https://github.com/actions/stale) that performs the following actions:
# 1) Adds "stale" label to issues that have "stat:awaiting-response" for more than 30 days meaning that since we don't have enough information we may potentially close such issue
# 2) Closes issues that have been marked as "stale" for more than 30 days

# This affects only Issues but at some point we may also consider rules for PRs

name: Mark and Close Stale Issues

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # Runs daily at midnight

jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write

steps:
- uses: actions/stale@v9
with:
# Only mark issues (not PRs) as stale
only-issue-labels: 'stat:awaiting-response'
days-before-stale: 30
days-before-close: 30
stale-issue-label: 'Stale'
stale-issue-message: >
This issue has been automatically marked as stale because it has been awaiting
response for over 30 days without any activity.

Please update the issue with any new information or it may be closed in 30 days.
close-issue-message: >
This issue has been automatically closed because it has been stale for 30 days
without any activity. Feel free to reopen if you have new information to add.
# Prevent the action from marking/closing PRs
days-before-pr-stale: -1
days-before-pr-close: -1
40 changes: 40 additions & 0 deletions .github/workflows/remove-labels-on-issue-close.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow will remove almost all labels from closed issues beside ones that could be relevant for future tracking like: "port:", "type:", "priority:", "regression" and "stat:imported"

name: Remove labels when issue is closed

on:
issues:
types: [closed] # We want it to run on closed issues

jobs:
remove_labels:
name: Calculate and remove issue labels
if: ${{ !github.event.issue.pull_request }} # This is needed to distinguish from PRs (which we don't want to affect)
runs-on: ubuntu-latest
permissions:
issues: write

steps:
- name: Find labels to remove
id: data
run: |
# Convert labels to array and filter out type: labels
LABELS_TO_REMOVE=($(echo "$EXISTING_LABELS" | jq -r '.[] | select(startswith("type:") or startswith("port:") or startswith("priority:") or . == "regression" or . == "stat:imported" | not)'))

# Only proceed if we have labels to remove
if [ ${#LABELS_TO_REMOVE[@]} -gt 0 ]; then
echo "REMOVE_LABELS=$(IFS=,; echo "${LABELS_TO_REMOVE[*]}")" >> $GITHUB_ENV
echo "HAS_LABELS=true" >> $GITHUB_ENV
else
echo "HAS_LABELS=false" >> $GITHUB_ENV
fi
env:
EXISTING_LABELS: ${{ toJson(github.event.issue.labels.*.name) }}

- name: Remove labels
if: ${{ env.REMOVE_LABELS != '' }}
run: gh issue edit "$NUMBER" --remove-label "$REMOVE_LABELS"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.issue.number }}