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 120a60d
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/label-epic-task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Label Child Issues

on:
issues:
types: [opened, edited]

jobs:
label_child_issues:
runs-on: ubuntu-latest
steps:
- name: Fetch Linked Issues
id: get_linked_issues
run: |
linked_issues=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/timeline \
| jq -r '.[] | select(.event == "cross-referenced") | .source.issue.number')
echo "Linked Issues: $linked_issues"
# Assuming there's only one linked parent issue
echo "PARENT_ISSUE=$(echo $linked_issues | head -n 1)" >> $GITHUB_ENV
- name: Get Labels from Parent Issue
id: get_labels
if: env.PARENT_ISSUE
run: |
labels=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${PARENT_ISSUE} \
| jq -r '.labels[] | select(.name != "epic") | .name')
# Add the epic-task label to the list
labels="$labels\nepic-task"
# Escape newlines for GitHub environment variable handling
formatted_labels="${labels//$'\n'/'%0A'}"
echo "LABELS=$formatted_labels" >> $GITHUB_ENV
- name: Apply Labels to Child Issue
if: env.PARENT_ISSUE
uses: actions-ecosystem/action-add-labels@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: ${{ env.LABELS }}

0 comments on commit 120a60d

Please sign in to comment.