-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove the PRT labels for new commits
- Loading branch information
1 parent
57db84f
commit 40f89a5
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Remove the PRT label, for the new commit | ||
|
||
on: | ||
pull_request: | ||
types: ["opened", "synchronize"] | ||
|
||
jobs: | ||
prt_labels: | ||
name: remove the PRT label, if it is a new commit | ||
runs-on: ubuntu-latest | ||
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 | ||
}); | ||
})); | ||
} |