From e8c13c1eb12c22bd5e3f870a89cde39d3025c435 Mon Sep 17 00:00:00 2001 From: Justin Hiemstra Date: Wed, 27 Nov 2024 18:33:34 +0000 Subject: [PATCH] GHA development --- .github/workflows/enforce-labelling.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/enforce-labelling.yml b/.github/workflows/enforce-labelling.yml index 3501e1f59..28f3fb385 100644 --- a/.github/workflows/enforce-labelling.yml +++ b/.github/workflows/enforce-labelling.yml @@ -25,9 +25,14 @@ jobs: - name: Validate PR is linked to an issue id: check_linked_issues run: | - PR_BODY=$(jq -r '.pull_request.body' $GITHUB_EVENT_PATH) - if ! echo "$PR_BODY" | grep -qE "#[0-9]+"; then - echo "No linked issues found in the pull request description." + PR_NUMBER=$(jq -r '.pull_request.number' $GITHUB_EVENT_PATH) + REPO_OWNER=$(jq -r '.repository.owner.login' $GITHUB_EVENT_PATH) + REPO_NAME=$(jq -r '.repository.name' $GITHUB_EVENT_PATH) + LINKED_ISSUES=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/issues/$PR_NUMBER/timeline" \ + | jq '[.[] | select(.event == "cross-referenced") | .source.issue.number] | length') + if [ "$LINKED_ISSUES" -eq "0" ]; then + echo "No linked issues found in the pull request." exit 1 fi