Skip to content

Commit

Permalink
remove the PRT labels for new commits
Browse files Browse the repository at this point in the history
  • Loading branch information
omkarkhatavkar committed Feb 22, 2024
1 parent 285315d commit 5353ee1
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/prt_labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Remove the PRT label, for the new commit

on:
pull_request:
types: ["synchronize"]

jobs:
prt_labels_remover:
name: remove the PRT label when amendments or new commits added to PR
runs-on: ubuntu-latest
if: "(contains(github.event.pull_request.labels.*.name, 'PRT-Passed') || contains(github.event.pull_request.labels.*.name, 'PRT-Failed'))"
steps:
- name: Fetch the PRT status
id: prt
uses: omkarkhatavkar/wait-for-status-checks@main
with:
ref: ${{ github.head_ref }}
context: 'Robottelo-Runner'
wait-interval: 2
count: 5

- name: remove the PRT Passed/Failed label, for new commit
if: always() && ${{steps.prt.outputs.result}} == 'not_found'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.CHERRYPICK_PAT }}
script: |
const prNumber = '${{ github.event.number }}';
const issue = await github.rest.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
});
const labelsToRemove = ['PRT-Failed', 'PRT-Passed'];
const labelsToRemoveFiltered = labelsToRemove.filter(label => issue.data.labels.some(({ name }) => name === label));
if (labelsToRemoveFiltered.length > 0) {
await Promise.all(labelsToRemoveFiltered.map(async label => {
await github.rest.issues.removeLabel({
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
name: label
});
}));
}

0 comments on commit 5353ee1

Please sign in to comment.