-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add github action to automatically label epic tasks (#168)
- Loading branch information
1 parent
c42f621
commit ab5b883
Showing
1 changed file
with
40 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,40 @@ | ||
name: Label Child Issues | ||
|
||
on: | ||
issues: | ||
types: [opened, edited] | ||
|
||
jobs: | ||
label_child_issues: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Fetch Linked Issue | ||
id: get_linked_issue | ||
run: | | ||
# Get the first linked issue (assumed to be the parent) | ||
linked_issue=$(curl -sH "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/timeline" \ | ||
| jq -r '.[] | select(.event == "cross-referenced") | .source.issue.number' | head -n 1) | ||
echo "PARENT_ISSUE=$linked_issue" >> $GITHUB_ENV | ||
- name: Get Parent Issue Labels | ||
if: env.PARENT_ISSUE | ||
run: | | ||
# Fetch labels from the parent issue | ||
parent_labels=$(curl -sH "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
"https://api.github.com/repos/${{ github.repository }}/issues/${{ env.PARENT_ISSUE }}" \ | ||
| jq -r '.labels[].name' | paste -sd,) | ||
echo "PARENT_LABELS=$parent_labels" >> $GITHUB_ENV | ||
- name: Apply Labels | ||
if: env.PARENT_ISSUE | ||
run: | | ||
# Combine "epic-task" with parent labels and apply to the current issue | ||
labels=$(echo "epic-task,${{ env.PARENT_LABELS }}" | jq -R 'split(",")') | ||
curl -X POST -sH "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "Content-Type: application/json" \ | ||
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/labels" \ | ||
-d "{\"labels\":$labels}" | ||
echo "Applied labels: epic-task,${{ env.PARENT_LABELS }}" |