From 2f60ad51bf4bea00c1a108adbebd339e13e617fb Mon Sep 17 00:00:00 2001 From: stuartmorgan-g Date: Thu, 19 Mar 2026 14:49:17 -0400 Subject: [PATCH 1/3] Add a workflow to auto-remove CICD label See https://github.com/flutter/flutter/pull/183675. This replicates that script to this repo, until such time as the entire flow is fully centralized. --- .github/remove_cicd.yaml | 65 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/remove_cicd.yaml diff --git a/.github/remove_cicd.yaml b/.github/remove_cicd.yaml new file mode 100644 index 00000000000..3830ef1dd9d --- /dev/null +++ b/.github/remove_cicd.yaml @@ -0,0 +1,65 @@ +# Copyright 2024 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +name: Remove outdated CICD Label + +on: + pull_request_target: + types: [synchronize] + +permissions: + pull-requests: write + issues: write + +jobs: + remove_cicd_label: + if: contains(github.event.pull_request.labels.*.name, 'CICD') + runs-on: ubuntu-latest + steps: + - name: Check if label was added before push + id: check_timing + run: | + # Get push time (commit date of the head SHA) + PUSH_TIME=$(gh api repos/${{ github.repository }}/commits/${{ github.event.pull_request.head.sha }} --jq '.commit.committer.date') + echo "Push time: $PUSH_TIME" + + # Get latest CICD labeling event time from the last 100 events + LABEL_TIME=$(gh api graphql -f query=' + query($owner: String!, $repo: String!, $pr: Int!) { + repository(owner: $owner, name: $repo) { + pullRequest(number: $pr) { + timelineItems(last: 100, itemTypes: [LABELED_EVENT]) { + nodes { + ... on LabeledEvent { + label { name } + createdAt + } + } + } + } + } + }' -f owner=${{ github.repository_owner }} -f repo=${{ github.event.repository.name }} -F pr=${{ github.event.pull_request.number }} \ + --jq '.data.repository.pullRequest.timelineItems.nodes | map(select(.label.name == "CICD")) | last | .createdAt') + echo "Label time: $LABEL_TIME" + + if [[ -z "$LABEL_TIME" ]]; then + # Label exists on PR (checked by job 'if') but not in last 100 events -> must be very old + echo "should_remove=true" >> "$GITHUB_OUTPUT" + echo "Result: Label found on PR but not in recent timeline events. Assuming it is old." + elif [[ "$LABEL_TIME" < "$PUSH_TIME" ]]; then + echo "should_remove=true" >> "$GITHUB_OUTPUT" + echo "Result: Label added at $LABEL_TIME is older than push at $PUSH_TIME. Removing." + else + echo "should_remove=false" >> "$GITHUB_OUTPUT" + echo "Result: Label added at $LABEL_TIME is newer than or same as push at $PUSH_TIME. Skipping removal." + fi + env: + GITHUB_TOKEN: ${{ github.token }} + + - name: Remove outdated CICD label + if: steps.check_timing.outputs.should_remove == 'true' + run: | + gh pr edit ${{ github.event.pull_request.number }} -R ${{ github.repository }} --remove-label "CICD" + env: + GITHUB_TOKEN: ${{ github.token }} From d936910d81d3c437677e08a2aa06b347750209bf Mon Sep 17 00:00:00 2001 From: stuartmorgan-g Date: Thu, 19 Mar 2026 16:58:38 -0400 Subject: [PATCH 2/3] Fix file extension --- .github/{remove_cicd.yaml => remove_cicd.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{remove_cicd.yaml => remove_cicd.yml} (100%) diff --git a/.github/remove_cicd.yaml b/.github/remove_cicd.yml similarity index 100% rename from .github/remove_cicd.yaml rename to .github/remove_cicd.yml From 410f672a462e3639e4a4c657bd8c2fad4f1ddf6f Mon Sep 17 00:00:00 2001 From: stuartmorgan-g Date: Fri, 20 Mar 2026 11:47:59 -0400 Subject: [PATCH 3/3] Update with https://github.com/flutter/flutter/pull/183905 --- .github/remove_cicd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/remove_cicd.yml b/.github/remove_cicd.yml index 3830ef1dd9d..6f5ff9d0596 100644 --- a/.github/remove_cicd.yml +++ b/.github/remove_cicd.yml @@ -21,7 +21,7 @@ jobs: id: check_timing run: | # Get push time (commit date of the head SHA) - PUSH_TIME=$(gh api repos/${{ github.repository }}/commits/${{ github.event.pull_request.head.sha }} --jq '.commit.committer.date') + PUSH_TIME='${{ github.event.pull_request.updated_at }}' echo "Push time: $PUSH_TIME" # Get latest CICD labeling event time from the last 100 events