-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update pr label on merge to closed (#207)
Co-authored-by: Pritish Budhiraja <[email protected]> Co-authored-by: Jeeva Ramachandran <[email protected]> Co-authored-by: Jeeva Ramachandran <[email protected]>
- Loading branch information
1 parent
94e70d3
commit f8994ff
Showing
1 changed file
with
46 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,46 @@ | ||
name: Update PR Label to Closed | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- closed | ||
|
||
jobs: | ||
pr-label: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get existing labels | ||
run: | | ||
PR_NUMBER=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH") | ||
TOKEN=$GITHUB_TOKEN | ||
# Add your repository name if it's not the default branch | ||
REPO_NAME=$(basename $GITHUB_REPOSITORY) | ||
# Get existing labels on the PR | ||
EXISTING_LABELS=$(curl -s -H "Authorization: Bearer ${{ secrets.AUTO_RELEASE_PAT }}" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
"https://api.github.com/repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER" \ | ||
| jq -r '.labels | map(.name) | join(" ")') | ||
echo $EXISTING_LABELS | ||
# Remove existing labels | ||
for LABEL in $EXISTING_LABELS; do | ||
curl -X DELETE \ | ||
-H 'Accept: application/vnd.github.v3+json' \ | ||
-H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ | ||
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/${LABEL}" | ||
done | ||
- name: Add new label | ||
run: | | ||
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} | ||
gh pr edit ${{ github.event.pull_request.number }} --add-label "closed" | ||