Skip to content

Commit

Permalink
Create push_event.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Omkar Khatavkar authored Feb 13, 2024
1 parent 5c771f2 commit 0b8cd5b
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/push_event.yml
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
});
}));
}
}

0 comments on commit 0b8cd5b

Please sign in to comment.