forked from SatelliteQE/robottelo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Omkar Khatavkar
authored
Feb 13, 2024
1 parent
5c771f2
commit 0b8cd5b
Showing
1 changed file
with
37 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,37 @@ | ||
# running specific actions related to push events | ||
name: Remove PRT labels for new commit | ||
on: | ||
push: | ||
|
||
jobs: | ||
remove-prt-labels: | ||
name: Remove PRT labels for new commit | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Remove the previous PRT Result labels | ||
if: contains(github.event.pull_request.labels.*.name, 'PRT') | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{ secrets.CHERRYPICK_PAT }} | ||
script: | | ||
if ('${{github.event_name}}' === 'push') { | ||
// Your code to handle the event due to new commit | ||
const prNumber = ${{ github.event.number }}; | ||
const issue = await github.rest.issues.get({ | ||
owner: context.issue.owner, | ||
repo: context.issue.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 | ||
}); | ||
})); | ||
} | ||
} |