Skip to content

Commit

Permalink
chore: Add github action to automatically label epic tasks (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
JabobKrauskopf committed Aug 14, 2024
1 parent c42f621 commit ab5b883
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/label-epic-task.yml
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 }}"

0 comments on commit ab5b883

Please sign in to comment.