From df23afa586aabf5e37090670cee8cea3082b7233 Mon Sep 17 00:00:00 2001 From: Emma Date: Wed, 8 Jan 2025 13:21:40 -0500 Subject: [PATCH 01/10] chore: Add action to auto update labels on comments --- .github/workflows/autolabel.yaml | 79 ++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .github/workflows/autolabel.yaml diff --git a/.github/workflows/autolabel.yaml b/.github/workflows/autolabel.yaml new file mode 100644 index 0000000000..6487487391 --- /dev/null +++ b/.github/workflows/autolabel.yaml @@ -0,0 +1,79 @@ +name: Update issue labels + +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 + +jobs: + setup: + name: Calculate Labels + if: ${{ !github.event.issue.pull_request }} && ${{ github.event.issue.state == 'open' }} + runs-on: ubuntu-latest + outputs: + add_labels: ${{ steps.data.outputs.add_labels }} + remove_labels: ${{ steps.data.outputs.remove_labels }} + + steps: + - name: Calculate Labels + id: data + run: | + ADD_LABELS=() + REMOVE_LABELS=() + + if [[ "${{ github.event.comment.author_association }}" == "MEMBER" ]]; then + ADD_LABELS+=${{ env.AWAITING_RESPONSE}} + else + REMOVE_LABELS+=${{ env.AWAITING_RESPONSE}} + fi + + echo "add_labels=$(IFS=,; echo "${ADD_LABELS[*]}")" >> $GITHUB_OUTPUT + echo "remove_labels=$(IFS=,; echo "${REMOVE_LABELS[*]}")" >> $GITHUB_OUTPUT + + manage_labels: + runs-on: ubuntu-latest + permissions: + issues: write + needs: [setup] + steps: + - name: Calculate add labels + id: add_labels + if: ${{ needs.setup.outputs.add_labels != '' }} + run: | + COMMAND="" + if [[ -n "${{ needs.setup.outputs.add_labels }}" ]]; then + COMMAND+="--add-label \"${{ needs.setup.outputs.add_labels }}\"" + fi + echo "ADD_LABEL=$COMMAND" >> $GITHUB_ENV + + - name: Calculate remove labels + id: remove_labels + if: ${{ needs.setup.outputs.remove_labels != '' }} + run: | + COMMAND="" + if [[ -n "${{ needs.setup.outputs.remove_labels }}" ]]; then + COMMAND+="--remove-label \"${{ needs.setup.outputs.remove_labels }}\"" + fi + echo "REMOVE_LABEL=$COMMAND" >> $GITHUB_ENV + + - name: Test Print Command + run: | + echo "gh issue edit "$NUMBER" $ADD_LABEL $REMOVE_LABEL" + env: + NUMBER: ${{ github.event.issue.number }} + + + # - run: gh issue edit "$NUMBER" --add-label "$ADD_LABELS" --remove-label "$REMOVE_LABELS" + # env: + # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # GH_REPO: ${{ github.repository }} + # NUMBER: ${{ github.event.issue.number }} + # ADD_LABELS: ${{ needs.setup.outputs.add_labels }} + # REMOVE_LABELS: ${{ needs.setup.outputs.remove_labels }} From bbadb744a4cb1677e83bbdbe72b59fc7da3d8818 Mon Sep 17 00:00:00 2001 From: Emma Date: Fri, 7 Mar 2025 19:40:24 -0500 Subject: [PATCH 02/10] Update syntax, add on-close action --- .github/workflows/autolabel.yaml | 61 +++++-------------- .../removel-labels-on-issue-close.yaml | 32 ++++++++++ 2 files changed, 46 insertions(+), 47 deletions(-) create mode 100644 .github/workflows/removel-labels-on-issue-close.yaml diff --git a/.github/workflows/autolabel.yaml b/.github/workflows/autolabel.yaml index 6487487391..ae4336b101 100644 --- a/.github/workflows/autolabel.yaml +++ b/.github/workflows/autolabel.yaml @@ -13,67 +13,34 @@ env: AWAITING_RESPONSE: stat:awaiting response jobs: - setup: - name: Calculate Labels + auto_label: + name: Calculate and update issue labels if: ${{ !github.event.issue.pull_request }} && ${{ github.event.issue.state == 'open' }} runs-on: ubuntu-latest - outputs: - add_labels: ${{ steps.data.outputs.add_labels }} - remove_labels: ${{ steps.data.outputs.remove_labels }} + permissions: + issues: write steps: - - name: Calculate Labels - id: data + - name: Calculate labels run: | ADD_LABELS=() REMOVE_LABELS=() if [[ "${{ github.event.comment.author_association }}" == "MEMBER" ]]; then - ADD_LABELS+=${{ env.AWAITING_RESPONSE}} + ADD_LABELS+="${{ env.AWAITING_RESPONSE}}" else - REMOVE_LABELS+=${{ env.AWAITING_RESPONSE}} + REMOVE_LABELS+="${{ env.AWAITING_RESPONSE}}" fi - echo "add_labels=$(IFS=,; echo "${ADD_LABELS[*]}")" >> $GITHUB_OUTPUT - echo "remove_labels=$(IFS=,; echo "${REMOVE_LABELS[*]}")" >> $GITHUB_OUTPUT - manage_labels: - runs-on: ubuntu-latest - permissions: - issues: write - needs: [setup] - steps: - - name: Calculate add labels - id: add_labels - if: ${{ needs.setup.outputs.add_labels != '' }} - run: | - COMMAND="" - if [[ -n "${{ needs.setup.outputs.add_labels }}" ]]; then - COMMAND+="--add-label \"${{ needs.setup.outputs.add_labels }}\"" - fi - echo "ADD_LABEL=$COMMAND" >> $GITHUB_ENV + # Add further label logic here - uses bash - - name: Calculate remove labels - id: remove_labels - if: ${{ needs.setup.outputs.remove_labels != '' }} - run: | - COMMAND="" - if [[ -n "${{ needs.setup.outputs.remove_labels }}" ]]; then - COMMAND+="--remove-label \"${{ needs.setup.outputs.remove_labels }}\"" - fi - echo "REMOVE_LABEL=$COMMAND" >> $GITHUB_ENV + echo "ADD_LABELS=$(IFS=,; echo "${ADD_LABELS[*]}")" >> $GITHUB_ENV + echo "REMOVE_LABELS=$(IFS=,; echo "${REMOVE_LABELS[*]}")" >> $GITHUB_ENV - - name: Test Print Command - run: | - echo "gh issue edit "$NUMBER" $ADD_LABEL $REMOVE_LABEL" + - name: Update labels + run: gh issue edit "$NUMBER" --add-label "$ADD_LABELS" --remove-label "$REMOVE_LABELS" env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} NUMBER: ${{ github.event.issue.number }} - - - # - run: gh issue edit "$NUMBER" --add-label "$ADD_LABELS" --remove-label "$REMOVE_LABELS" - # env: - # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # GH_REPO: ${{ github.repository }} - # NUMBER: ${{ github.event.issue.number }} - # ADD_LABELS: ${{ needs.setup.outputs.add_labels }} - # REMOVE_LABELS: ${{ needs.setup.outputs.remove_labels }} diff --git a/.github/workflows/removel-labels-on-issue-close.yaml b/.github/workflows/removel-labels-on-issue-close.yaml new file mode 100644 index 0000000000..b6c6050ebc --- /dev/null +++ b/.github/workflows/removel-labels-on-issue-close.yaml @@ -0,0 +1,32 @@ +name: Remove all labels when issue is closed + +on: + issues: + types: [closed] + +jobs: + auto_label: + name: Calculate and update issue labels + if: ${{ !github.event.issue.pull_request }} + runs-on: ubuntu-latest + permissions: + issues: write + + steps: + - name: Find labels + id: data + run: | + # Use jq to parse the JSON array and convert to bash array + LABELS=($(echo "$EXISTING_LABELS" | jq -r '.[]')) + + # Format the labels for the gh command + echo "REMOVE_LABELS=$(IFS=,; echo "${LABELS[*]}")" >> $GITHUB_ENV + env: + EXISTING_LABELS: ${{ toJson(github.event.issue.labels.*.name) }} + + - name: 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 }} From 07b603d07821fb6268b1a509fed9ca47eb110889 Mon Sep 17 00:00:00 2001 From: Emma Date: Wed, 12 Mar 2025 14:36:37 -0400 Subject: [PATCH 03/10] temp --- .github/workflows/autolabel.yaml | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/autolabel.yaml b/.github/workflows/autolabel.yaml index ae4336b101..f376a4ad15 100644 --- a/.github/workflows/autolabel.yaml +++ b/.github/workflows/autolabel.yaml @@ -1,5 +1,8 @@ name: Update issue labels +# 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] @@ -23,23 +26,18 @@ jobs: steps: - name: Calculate labels run: | - ADD_LABELS=() - REMOVE_LABELS=() if [[ "${{ github.event.comment.author_association }}" == "MEMBER" ]]; then - ADD_LABELS+="${{ env.AWAITING_RESPONSE}}" + echo ADD="${{ env.AWAITING_RESPONSE}}" >> $GITHUB_ENV else - REMOVE_LABELS+="${{ env.AWAITING_RESPONSE}}" + echo REMOVE="${{ env.AWAITING_RESPONSE}}" >> $GITHUB_ENV fi - - # Add further label logic here - uses bash - - echo "ADD_LABELS=$(IFS=,; echo "${ADD_LABELS[*]}")" >> $GITHUB_ENV - echo "REMOVE_LABELS=$(IFS=,; echo "${REMOVE_LABELS[*]}")" >> $GITHUB_ENV - - name: Update labels - run: gh issue edit "$NUMBER" --add-label "$ADD_LABELS" --remove-label "$REMOVE_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 }} From 6cbdbb009beb28dd140d7f9350b4f3ba5fc3b1f8 Mon Sep 17 00:00:00 2001 From: michalChrobot Date: Tue, 18 Mar 2025 12:20:20 +0100 Subject: [PATCH 04/10] Added stat:reply-needed label handling --- ...utolabel.yaml => conversation-labels.yaml} | 19 ++++++--- .../remove-labels-on-issue-close.yaml | 40 +++++++++++++++++++ .../removel-labels-on-issue-close.yaml | 32 --------------- 3 files changed, 53 insertions(+), 38 deletions(-) rename .github/workflows/{autolabel.yaml => conversation-labels.yaml} (59%) create mode 100644 .github/workflows/remove-labels-on-issue-close.yaml delete mode 100644 .github/workflows/removel-labels-on-issue-close.yaml diff --git a/.github/workflows/autolabel.yaml b/.github/workflows/conversation-labels.yaml similarity index 59% rename from .github/workflows/autolabel.yaml rename to .github/workflows/conversation-labels.yaml index f376a4ad15..83eca10968 100644 --- a/.github/workflows/autolabel.yaml +++ b/.github/workflows/conversation-labels.yaml @@ -1,4 +1,6 @@ -name: Update issue labels +# 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 @@ -13,11 +15,12 @@ concurrency: # Define labels here env: - AWAITING_RESPONSE: stat:awaiting response + AWAITING_RESPONSE: stat:awaiting-response + REPLY_NEEDED: stat:reply-needed jobs: - auto_label: - name: Calculate and update issue labels + 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: @@ -28,9 +31,13 @@ jobs: run: | if [[ "${{ github.event.comment.author_association }}" == "MEMBER" ]]; then - echo ADD="${{ env.AWAITING_RESPONSE}}" >> $GITHUB_ENV + # Unity member commented - add awaiting-response, remove reply-needed + echo "ADD=${{ env.AWAITING_RESPONSE }}" >> $GITHUB_ENV + echo "REMOVE=${{ env.REPLY_NEEDED }}" >> $GITHUB_ENV else - echo REMOVE="${{ env.AWAITING_RESPONSE}}" >> $GITHUB_ENV + # 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 diff --git a/.github/workflows/remove-labels-on-issue-close.yaml b/.github/workflows/remove-labels-on-issue-close.yaml new file mode 100644 index 0000000000..f86ad0e90d --- /dev/null +++ b/.github/workflows/remove-labels-on-issue-close.yaml @@ -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:" and "regression" + +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" | 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.HAS_LABELS == 'true' + run: gh issue edit "$NUMBER" --remove-label "$REMOVE_LABELS" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + NUMBER: ${{ github.event.issue.number }} diff --git a/.github/workflows/removel-labels-on-issue-close.yaml b/.github/workflows/removel-labels-on-issue-close.yaml deleted file mode 100644 index b6c6050ebc..0000000000 --- a/.github/workflows/removel-labels-on-issue-close.yaml +++ /dev/null @@ -1,32 +0,0 @@ -name: Remove all labels when issue is closed - -on: - issues: - types: [closed] - -jobs: - auto_label: - name: Calculate and update issue labels - if: ${{ !github.event.issue.pull_request }} - runs-on: ubuntu-latest - permissions: - issues: write - - steps: - - name: Find labels - id: data - run: | - # Use jq to parse the JSON array and convert to bash array - LABELS=($(echo "$EXISTING_LABELS" | jq -r '.[]')) - - # Format the labels for the gh command - echo "REMOVE_LABELS=$(IFS=,; echo "${LABELS[*]}")" >> $GITHUB_ENV - env: - EXISTING_LABELS: ${{ toJson(github.event.issue.labels.*.name) }} - - - name: 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 }} From 8c10d1ddbfc2477e28920dbeb6c0418df3583f6b Mon Sep 17 00:00:00 2001 From: michalChrobot Date: Tue, 18 Mar 2025 12:40:09 +0100 Subject: [PATCH 05/10] Added workflow for marking stale issues --- .github/workflows/mark-stale-issue.yaml | 59 +++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/mark-stale-issue.yaml diff --git a/.github/workflows/mark-stale-issue.yaml b/.github/workflows/mark-stale-issue.yaml new file mode 100644 index 0000000000..707582f289 --- /dev/null +++ b/.github/workflows/mark-stale-issue.yaml @@ -0,0 +1,59 @@ +name: Mark Stale Issues + +on: + schedule: + - cron: '0 0 * * *' # Runs daily at midnight + +env: + AWAITING-RESPONSE_LABEL: stat:awaiting-response + STALE_LABEL: stale + DAYS_BEFORE_STALE: 60 # 2 months + +jobs: + mark_stale: + name: Check and Mark Stale Issues + if: ${{ !github.event.issue.pull_request }} && ${{ github.event.issue.state == 'open' }} + runs-on: ubuntu-latest + permissions: + issues: write + + steps: + - name: Get Issues with Awaiting Response + id: get_issues + run: | + # Get all open issues with awaiting-response label + ISSUES=$(gh issue list --label "${{ env.AWAITING-RESPONSE_LABEL }}" --json number,labels,updatedAt --jq '.[]') + + echo "ISSUES=$ISSUES" >> $GITHUB_ENV + + - name: Process Issues + run: | + current_time=$(date +%s) + + echo "$ISSUES" | while read -r issue; do + # Extract issue details + number=$(echo "$issue" | jq -r .number) + updated_at=$(echo "$issue" | jq -r .updatedAt) + has_stale=$(echo "$issue" | jq -r '.labels[].name | select(. == "stale")' || echo "") + + # Convert updated_at to timestamp + updated_time=$(date -d "$updated_at" +%s) + + # Calculate days difference + days_diff=$(( (current_time - updated_time) / 86400 )) + + # Check if issue should be marked stale + if [[ $days_diff -ge ${{ env.DAYS_BEFORE_STALE }} && -z "$has_stale" ]]; then + echo "Marking issue #$number as stale" + gh issue edit "$number" --add-label "${{ env.STALE_LABEL }}" \ + --body-file <( + echo "This issue has been automatically marked as stale because it has been awaiting response for over 2 months without any activity." + echo "" + echo "Please update the issue with any new information or it may be closed in the future." + ) + fi + done + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + From d3049104c85585e67028aab27875fc3e3071aa4c Mon Sep 17 00:00:00 2001 From: michalChrobot Date: Tue, 18 Mar 2025 12:40:35 +0100 Subject: [PATCH 06/10] Added workflow for managing assigning and unassignig from an issue --- .github/workflows/assignee-management.yaml | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 .github/workflows/assignee-management.yaml diff --git a/.github/workflows/assignee-management.yaml b/.github/workflows/assignee-management.yaml new file mode 100644 index 0000000000..078da886c3 --- /dev/null +++ b/.github/workflows/assignee-management.yaml @@ -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 Label Creator + 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 }} From 8bfb5fcf0adcc6323b43bd5bcb5526a594dfc2f0 Mon Sep 17 00:00:00 2001 From: michalChrobot Date: Tue, 18 Mar 2025 12:41:32 +0100 Subject: [PATCH 07/10] Added possibility of an manual trigger --- .github/workflows/mark-stale-issue.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/mark-stale-issue.yaml b/.github/workflows/mark-stale-issue.yaml index 707582f289..04c6de6b2f 100644 --- a/.github/workflows/mark-stale-issue.yaml +++ b/.github/workflows/mark-stale-issue.yaml @@ -1,6 +1,7 @@ name: Mark Stale Issues on: + workflow_dispatch: schedule: - cron: '0 0 * * *' # Runs daily at midnight From eeaaae12f8bcb8c4ff74fdabf6a44d8c38491baa Mon Sep 17 00:00:00 2001 From: michalChrobot Date: Tue, 18 Mar 2025 15:36:44 +0100 Subject: [PATCH 08/10] Added stat:import label to the list of exclusion when deleting labels from closed issues --- .github/workflows/remove-labels-on-issue-close.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/remove-labels-on-issue-close.yaml b/.github/workflows/remove-labels-on-issue-close.yaml index f86ad0e90d..af1c7c0908 100644 --- a/.github/workflows/remove-labels-on-issue-close.yaml +++ b/.github/workflows/remove-labels-on-issue-close.yaml @@ -19,7 +19,7 @@ jobs: 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" | not)')) + 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 From 58550efdf32afdef78301cc840bffdedff606270 Mon Sep 17 00:00:00 2001 From: michalChrobot Date: Tue, 18 Mar 2025 16:01:47 +0100 Subject: [PATCH 09/10] Comments added and rfc template removed --- .github/ISSUE_TEMPLATE/rfc-tracking-issue.md | 10 ---------- .github/workflows/assignee-management.yaml | 4 ++-- .github/workflows/mark-stale-issue.yaml | 4 +++- .github/workflows/remove-labels-on-issue-close.yaml | 2 +- 4 files changed, 6 insertions(+), 14 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/rfc-tracking-issue.md diff --git a/.github/ISSUE_TEMPLATE/rfc-tracking-issue.md b/.github/ISSUE_TEMPLATE/rfc-tracking-issue.md deleted file mode 100644 index 3b112ff8bb..0000000000 --- a/.github/ISSUE_TEMPLATE/rfc-tracking-issue.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -name: RFC Tracking Issue -about: Track the development of a RFC -title: 'Track RFC #: ' -labels: stat:awaiting-triage, stat:reply-needed -assignees: '' - ---- - -Tracking issue for [RFC #: ](https://github.com/Unity-Technologies/com.unity.multiplayer.rfcs/pull/) diff --git a/.github/workflows/assignee-management.yaml b/.github/workflows/assignee-management.yaml index 078da886c3..9c65e3338a 100644 --- a/.github/workflows/assignee-management.yaml +++ b/.github/workflows/assignee-management.yaml @@ -15,7 +15,7 @@ on: types: [assigned, unassigned, labeled] env: - AWAITING-TRIAGE_LABEL: stat:awaiting triage + AWAITING-TRIAGE_LABEL: stat:awaiting-triage INVESTIGATING_LABEL: stat:Investigating jobs: @@ -59,7 +59,7 @@ jobs: issues: write steps: - - name: Assign Issue to Label Creator + - 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" diff --git a/.github/workflows/mark-stale-issue.yaml b/.github/workflows/mark-stale-issue.yaml index 04c6de6b2f..435630c5a6 100644 --- a/.github/workflows/mark-stale-issue.yaml +++ b/.github/workflows/mark-stale-issue.yaml @@ -1,4 +1,6 @@ -name: Mark Stale Issues +# This workflow add "stale" label to issues that have "stat:awaiting-response" for more than 60 days meaning that since we don't have enough information we may potentially close such issue + +name: Mark Stale Issues on: workflow_dispatch: diff --git a/.github/workflows/remove-labels-on-issue-close.yaml b/.github/workflows/remove-labels-on-issue-close.yaml index af1c7c0908..c8f289c6d3 100644 --- a/.github/workflows/remove-labels-on-issue-close.yaml +++ b/.github/workflows/remove-labels-on-issue-close.yaml @@ -1,4 +1,4 @@ -# 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" +# 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 From c78d5b294b34bbc86da94fb7d05d38d16da466f1 Mon Sep 17 00:00:00 2001 From: michalChrobot Date: Tue, 1 Apr 2025 14:04:32 +0200 Subject: [PATCH 10/10] Added preimplemented stale GitHub action --- .github/workflows/mark-stale-issue.yaml | 74 +++++++------------ .../remove-labels-on-issue-close.yaml | 2 +- 2 files changed, 26 insertions(+), 50 deletions(-) diff --git a/.github/workflows/mark-stale-issue.yaml b/.github/workflows/mark-stale-issue.yaml index 435630c5a6..4ca2b11948 100644 --- a/.github/workflows/mark-stale-issue.yaml +++ b/.github/workflows/mark-stale-issue.yaml @@ -1,62 +1,38 @@ -# This workflow add "stale" label to issues that have "stat:awaiting-response" for more than 60 days meaning that since we don't have enough information we may potentially close such issue +# 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 -name: Mark Stale Issues +# 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 -env: - AWAITING-RESPONSE_LABEL: stat:awaiting-response - STALE_LABEL: stale - DAYS_BEFORE_STALE: 60 # 2 months - jobs: - mark_stale: - name: Check and Mark Stale Issues - if: ${{ !github.event.issue.pull_request }} && ${{ github.event.issue.state == 'open' }} + stale: runs-on: ubuntu-latest permissions: issues: write - + steps: - - name: Get Issues with Awaiting Response - id: get_issues - run: | - # Get all open issues with awaiting-response label - ISSUES=$(gh issue list --label "${{ env.AWAITING-RESPONSE_LABEL }}" --json number,labels,updatedAt --jq '.[]') - - echo "ISSUES=$ISSUES" >> $GITHUB_ENV - - - name: Process Issues - run: | - current_time=$(date +%s) - - echo "$ISSUES" | while read -r issue; do - # Extract issue details - number=$(echo "$issue" | jq -r .number) - updated_at=$(echo "$issue" | jq -r .updatedAt) - has_stale=$(echo "$issue" | jq -r '.labels[].name | select(. == "stale")' || echo "") - - # Convert updated_at to timestamp - updated_time=$(date -d "$updated_at" +%s) - - # Calculate days difference - days_diff=$(( (current_time - updated_time) / 86400 )) - - # Check if issue should be marked stale - if [[ $days_diff -ge ${{ env.DAYS_BEFORE_STALE }} && -z "$has_stale" ]]; then - echo "Marking issue #$number as stale" - gh issue edit "$number" --add-label "${{ env.STALE_LABEL }}" \ - --body-file <( - echo "This issue has been automatically marked as stale because it has been awaiting response for over 2 months without any activity." - echo "" - echo "Please update the issue with any new information or it may be closed in the future." - ) - fi - done - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GH_REPO: ${{ github.repository }} + - 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 diff --git a/.github/workflows/remove-labels-on-issue-close.yaml b/.github/workflows/remove-labels-on-issue-close.yaml index c8f289c6d3..2ac5145e16 100644 --- a/.github/workflows/remove-labels-on-issue-close.yaml +++ b/.github/workflows/remove-labels-on-issue-close.yaml @@ -32,7 +32,7 @@ jobs: EXISTING_LABELS: ${{ toJson(github.event.issue.labels.*.name) }} - name: Remove labels - if: env.HAS_LABELS == 'true' + if: ${{ env.REMOVE_LABELS != '' }} run: gh issue edit "$NUMBER" --remove-label "$REMOVE_LABELS" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}