From ca7005bcb99ff3fba952fe711f32385a963f0c0d Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Thu, 15 Aug 2024 20:22:14 -0400 Subject: [PATCH 1/2] feat: do not create a new issue if one already exists --- .github/workflows/cargo-generate.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/cargo-generate.yaml b/.github/workflows/cargo-generate.yaml index 8a50adf..c334dfd 100644 --- a/.github/workflows/cargo-generate.yaml +++ b/.github/workflows/cargo-generate.yaml @@ -92,6 +92,20 @@ jobs: # This is required to use the `gh` CLI. GH_TOKEN: ${{ github.token }} run: | + # Get a list of the IDs of open issues created by this action, then count them using JQ. + OPEN_ISSUES="$( + gh issue list \ + --search "is:issue is:open author:app/github-actions in:title $TITLE" \ + --json id \ + --jq '. | length' + )" + + # If an issue already exists, do not create another. + if [[ $OPEN_ISSUES -gt 0 ]]; then + echo "An issue already exists on merge conflicts! Exiting without creating another." + exit 0 + fi + GIT_STATUS="$(git status)" # Filter the diff to only include files with merge conflicts. From 7bf5d68d6fe36cb0ef6739f455c321d2f8ea2b5f Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Fri, 16 Aug 2024 11:50:03 -0400 Subject: [PATCH 2/2] feat: use quotes in certain scenarios Co-authored-by: Ben Frankel --- .github/workflows/cargo-generate.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cargo-generate.yaml b/.github/workflows/cargo-generate.yaml index c334dfd..3bd4936 100644 --- a/.github/workflows/cargo-generate.yaml +++ b/.github/workflows/cargo-generate.yaml @@ -95,14 +95,14 @@ jobs: # Get a list of the IDs of open issues created by this action, then count them using JQ. OPEN_ISSUES="$( gh issue list \ - --search "is:issue is:open author:app/github-actions in:title $TITLE" \ + --search "is:issue is:open author:app/github-actions in:title ${TITLE}" \ --json id \ --jq '. | length' )" # If an issue already exists, do not create another. - if [[ $OPEN_ISSUES -gt 0 ]]; then - echo "An issue already exists on merge conflicts! Exiting without creating another." + if [[ "${OPEN_ISSUES}" -gt 0 ]]; then + echo 'An issue already exists on merge conflicts! Exiting without creating another.' exit 0 fi