From 3600aa5ee656267f9de866fe3d14fe5ccfb087c5 Mon Sep 17 00:00:00 2001 From: Emanuel Cino Date: Thu, 5 Nov 2026 12:15:44 +0100 Subject: [PATCH] ADD workflow labelling open PRs on-stage Assisted-by: claude-sonnet-5-5, medium, claude-code --- .github/workflows/label-on-stage.yml | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/label-on-stage.yml diff --git a/.github/workflows/label-on-stage.yml b/.github/workflows/label-on-stage.yml new file mode 100644 index 000000000..70995263a --- /dev/null +++ b/.github/workflows/label-on-stage.yml @@ -0,0 +1,34 @@ +name: Label on-stage + +on: + push: + branches: + - stage + +permissions: + contents: read + pull-requests: write + +jobs: + label: + runs-on: ubuntu-latest + steps: + - name: Add the on-stage label to open PRs pushed on stage + env: + GH_TOKEN: ${{ github.token }} + REPO: ${{ github.repository }} + BEFORE: ${{ github.event.before }} + AFTER: ${{ github.sha }} + run: | + shas="$AFTER" + if [ "$BEFORE" != "0000000000000000000000000000000000000000" ]; then + shas=$(gh api --paginate "repos/$REPO/compare/$BEFORE...$AFTER" \ + --jq '.commits[].sha') || shas="$AFTER" + fi + for sha in $shas; do + gh api "repos/$REPO/commits/$sha/pulls" \ + --jq '.[] | select(.state == "open") | .number' + done | sort -un | while read -r pr; do + echo "Adding on-stage to PR #$pr" + gh api -X POST "repos/$REPO/issues/$pr/labels" -f "labels[]=on-stage" + done