Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
jhiemstrawisc committed Nov 27, 2024
1 parent 5948f27 commit 7813d6d
Showing 1 changed file with 0 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
pull_request:
# one limitation here is that there's no trigger to re-run any time we "connect" or "disconnect" an issue
types: [opened, edited, labeled, unlabeled, synchronize]
issues:
types: [opened, edited, labeled, unlabeled, closed]

jobs:
validate-pr:
Expand Down Expand Up @@ -55,49 +53,3 @@ jobs:
else
echo "Linked issues found: $LINKED_ISSUES"
fi
validate-issue:
runs-on: ubuntu-latest
if: github.event.action == 'closed'
steps:
- name: Check out the repository
uses: actions/checkout@v2

- name: Validate issue has labels
id: check_labels
run: |
ISSUE_LABELS=$(jq -r '.issue.labels | length' $GITHUB_EVENT_PATH)
if [ "$ISSUE_LABELS" -eq "0" ]; then
echo "No labels found on the issue."
exit 1
fi
- name: Validate issue is linked to a PR
id: check_linked_prs
run: |
ISSUE_NUMBER=$(jq -r '.issue.number' $GITHUB_EVENT_PATH)
REPO_OWNER=$(jq -r '.repository.owner.login' $GITHUB_EVENT_PATH)
REPO_NAME=$(jq -r '.repository.name' $GITHUB_EVENT_PATH)
TIMELINE_JSON=$(curl -s "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/issues/$ISSUE_NUMBER/timeline")
LINKED_PRS=$(echo "$TIMELINE_JSON" | jq '
reduce .[] as $event (
0;
if $event.event == "connected" then
. + 1
elif $event.event == "disconnected" then
. - 1
else
.
end
)')
if [ "$LINKED_PRS" -eq "0" ]; then
echo "❌ No linked pull requests found in the issue."
exit 1
elif [ "$LINKED_PRS" -lt "0" ]; then
echo "Error: More disconnected events than connected events. This shouldn't be possible and likely indicates a big ol' 🪲"
exit 1
else
echo "Linked PRs found: $LINKED_PRS"
fi

0 comments on commit 7813d6d

Please sign in to comment.