This repository was archived by the owner on Oct 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
43 lines (36 loc) · 1.53 KB
/
label-priority.yml
File metadata and controls
43 lines (36 loc) · 1.53 KB
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
38
39
40
41
42
43
name: Label Priority Based on Task Template
on:
issues:
types: [opened, edited]
jobs:
apply_priority_label:
runs-on: ubuntu-latest
steps:
- name: Check priority and apply label
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
ISSUE_NUMBER=${{ github.event.issue.number }}
PRIORITY=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE_NUMBER |
jq -r '.body' | grep -oP "(?<=### Priority:\n\n).+")
curl -s -X DELETE -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE_NUMBER/labels
if [[ "$PRIORITY" == "Critical" ]]; then
LABEL="priority: Critical"
elif [[ "$PRIORITY" == "High" ]]; then
LABEL="priority: High"
elif [[ "$PRIORITY" == "Medium" ]]; then
LABEL="priority: Medium"
elif [[ "$PRIORITY" == "Low" ]]; then
LABEL="priority: Low"
else
echo "No matching priority found."
exit 0
fi
curl -s -X POST -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
-d "{\"labels\":[\"$LABEL\"]}" \
https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE_NUMBER/labels