ci: ensure retrigger-ci label is cleaned up after every CI run

- Previously the label was only removed when it was the labeled event
    that triggered the workflow. If a PR was synchronized or reopened
    while the label was already present, it would not be removed by
    the workflow.
  - Created a dedicated cleanup job that depends on all other jobs
    with if: always(), ensuring it runs regardless of whether upstream
    jobs succeeded, failed, or were skipped.
  - Now the cleanup runs on every pull_request_target event and removes
    the label if present, ensuring it is always cleared after CI completes.

Co-authored-by: Jaroslava Fiedlerova <jaroslava.fiedlerova@openairinterface.org>
Signed-off-by: Shubhika Garg <shubhika.garg@openairinterface.org>
This commit is contained in:
Shubhika Garg
2026-06-18 11:45:45 +02:00
parent a5f60811c5
commit 328968cecf

View File

@@ -166,8 +166,24 @@ jobs:
-H "X-Github-Hook-Installation-Target-Type: repository" \
--data @/tmp/filtered_payload.json
cleanup:
needs:
- verify-signed-commits
- check-labels
- detect-changes
- require-maintainer-approval
- trigger-jenkins
if: always() && github.event_name == 'pull_request_target'
runs-on: ubuntu-24.04
steps:
- name: Remove retrigger-ci label
if: always() && github.event.action == 'labeled' && github.event.label.name == vars.RETRIGGER_CI_LABEL
run: gh pr edit ${{ github.event.pull_request.number }} --remove-label "${{ vars.RETRIGGER_CI_LABEL }}"
run: |
PR_LABELS=$(echo '${{ toJson(github.event.pull_request.labels) }}' | jq -r '.[].name')
if echo "$PR_LABELS" | grep -qxF "${{ vars.RETRIGGER_CI_LABEL }}"; then
gh pr edit ${{ github.event.pull_request.number }} --remove-label "${{ vars.RETRIGGER_CI_LABEL }}" --repo ${{ github.repository }}
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}