fix: DockerFile #605
This file contains hidden or 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
name: Update PR Label to Closed | |
on: | |
pull_request: | |
types: | |
- closed | |
jobs: | |
pr-label: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Remove all labels and add 'closed' | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
echo "Reading PR number..." | |
PR_NUMBER=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH") | |
echo "PR number: $PR_NUMBER" | |
echo "Fetching current labels..." | |
RESPONSE=$(curl -s -H "Authorization: Bearer $GH_TOKEN" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
"https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}") | |
echo "API Response: $RESPONSE" | |
EXISTING_LABELS=$(echo "$RESPONSE" | jq -r '[.labels[]?.name] | join(" ")') | |
echo "Existing labels: $EXISTING_LABELS" | |
if [ -z "$EXISTING_LABELS" ]; then | |
echo "No labels to remove." | |
else | |
for LABEL in $EXISTING_LABELS; do | |
echo "Removing label: $LABEL" | |
curl -X DELETE \ | |
-H "Authorization: Bearer $GH_TOKEN" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
"https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/labels/${LABEL}" | |
done | |
fi | |
echo "Adding 'closed' label..." | |
curl -X POST \ | |
-H "Authorization: Bearer $GH_TOKEN" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
--data '{"labels":["closed"]}' \ | |
"https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/labels" |