mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-11-22 05:12:27 +00:00
fix stuff
- enhance logic - fix logic to get PR body as plain text
This commit is contained in:
parent
903dfb37c5
commit
5e83ca55e7
24
.github/workflows/pr-labels.yaml
vendored
24
.github/workflows/pr-labels.yaml
vendored
|
@ -9,8 +9,9 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Analyze PR Body and manage labels
|
- name: Analyze PR Body and manage labels
|
||||||
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
body="${{ github.event.pull_request.body }}"
|
body=$(jq -r '.pull_request.body' "$GITHUB_EVENT_PATH")
|
||||||
labels_to_add=()
|
labels_to_add=()
|
||||||
labels_to_remove=()
|
labels_to_remove=()
|
||||||
declare -A label_checks=(
|
declare -A label_checks=(
|
||||||
|
@ -20,19 +21,23 @@ jobs:
|
||||||
["Refactoring"]="refactor"
|
["Refactoring"]="refactor"
|
||||||
["UI/UX improvement"]="UI/UX"
|
["UI/UX improvement"]="UI/UX"
|
||||||
)
|
)
|
||||||
for key in "${!label_checks[@]}"; do
|
for pattern in "${!label_checks[@]}"; do
|
||||||
if echo "$body" | grep -q "\- \[x\] $key"; then
|
label="${label_checks[$pattern]}"
|
||||||
labels_to_add+=("${label_checks[$key]}")
|
if echo "$body" | grep -Eq "\- \[x\] ($pattern)"; then
|
||||||
|
labels_to_add+=("$label")
|
||||||
else
|
else
|
||||||
labels_to_remove+=("${label_checks[$key]}")
|
labels_to_remove+=("$label")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo "LABELS_TO_ADD=${labels_to_add[*]}" >> $GITHUB_ENV
|
|
||||||
echo "LABELS_TO_REMOVE=${labels_to_remove[*]}" >> $GITHUB_ENV
|
echo "LABELS_TO_ADD=$(IFS=,; echo "${labels_to_add[*]}")" >> $GITHUB_ENV
|
||||||
|
echo "LABELS_TO_REMOVE=$(IFS=,; echo "${labels_to_remove[*]}")" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Add labels if necessary
|
- name: Add labels if necessary
|
||||||
if: env.LABELS_TO_ADD != ''
|
if: env.LABELS_TO_ADD != ''
|
||||||
run: |
|
run: |
|
||||||
for label in ${{ env.LABELS_TO_ADD }}; do
|
IFS=',' read -ra labels <<< "${LABELS_TO_ADD}"
|
||||||
|
for label in "${labels[@]}"; do
|
||||||
curl -s -X POST \
|
curl -s -X POST \
|
||||||
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
||||||
-H "Accept: application/vnd.github.v3+json" \
|
-H "Accept: application/vnd.github.v3+json" \
|
||||||
|
@ -42,7 +47,8 @@ jobs:
|
||||||
- name: Remove labels if necessary
|
- name: Remove labels if necessary
|
||||||
if: env.LABELS_TO_REMOVE != ''
|
if: env.LABELS_TO_REMOVE != ''
|
||||||
run: |
|
run: |
|
||||||
for label in ${{ env.LABELS_TO_REMOVE }}; do
|
IFS=',' read -ra labels <<< "${LABELS_TO_REMOVE}"
|
||||||
|
for label in "${labels[@]}"; do
|
||||||
curl -s -X DELETE \
|
curl -s -X DELETE \
|
||||||
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
||||||
-H "Accept: application/vnd.github.v3+json" \
|
-H "Accept: application/vnd.github.v3+json" \
|
||||||
|
|
Loading…
Reference in New Issue
Block a user