-
Notifications
You must be signed in to change notification settings - Fork 450
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
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 1d2828b
Merge branch 'develop' into chore/add_auto_labeler
NoelStephensUnity 53ec291
Merge branch 'develop' into chore/add_auto_labeler
NoelStephensUnity 0f0b3ab
Merge branch 'develop' of https://github.com/Unity-Technologies/com.u…
EmandM bbadb74
Update syntax, add on-close action
EmandM 0cd6449
Merge branch 'develop' into chore/add_auto_labeler
EmandM 07b603d
temp
EmandM b2f53fd
Merge branch 'develop' into chore/add_auto_labeler
NoelStephensUnity 6cbdbb0
Added stat:reply-needed label handling
michalChrobot d3db9b6
Merge branch 'develop' into chore/add_auto_labeler
michalChrobot 8c10d1d
Added workflow for marking stale issues
michalChrobot d304910
Added workflow for managing assigning and unassignig from an issue
michalChrobot 8bfb5fc
Added possibility of an manual trigger
michalChrobot 672ed1e
Merge branch 'chore/add_auto_labeler' of https://github.com/Unity-Tec…
michalChrobot eeaaae1
Added stat:import label to the list of exclusion when deleting labels…
michalChrobot 2921422
Merge branch 'develop' into chore/add_auto_labeler
michalChrobot 58550ef
Comments added and rfc template removed
michalChrobot e7e9ee9
Merge branch 'develop' into chore/add_auto_labeler
michalChrobot 1c1960a
Merge branch 'develop' into chore/add_auto_labeler
EmandM 2474f90
Merge branch 'develop' into chore/add_auto_labeler
michalChrobot c78d5b2
Added preimplemented stale GitHub action
michalChrobot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.