forked from SatelliteQE/robottelo
-
Notifications
You must be signed in to change notification settings - Fork 0
37 lines (36 loc) · 1.44 KB
/
push_event.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
});
}));
}
}