Merge branch 'master' into omkarkhatavkar-patch-26 #13
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
# 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: | |
- uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
- name: Get Pull Request Number | |
id: pr | |
run: echo "::set-output name=pull_request_number::$(gh pr view --json number -q .number || echo "")" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- run: echo ${{ steps.pr.outputs.pull_request_number }} | |
- name: Remove the previous PRT Result labels | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.CHERRYPICK_PAT }} | |
script: | | |
const prNumber = await github.rest.repos.listPullRequestsAssociatedWithCommit({ | |
commit_sha: context.sha, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
}).data[0].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: github.context.repo.owner, | |
repo: github.context.repo.repo, | |
name: label | |
}); | |
})); | |
} | |