-
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 120a60d
Showing
1 changed file
with
45 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,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 }} |