@@ -36,15 +36,34 @@ jobs:
3636 output="$(./bin/configlet sync --tests | tee .github/auto-sync/sync-test-output.txt)"
3737 echo "configlet output:"
3838 echo "$output"
39- echo "output<<EOF" >> $GITHUB_OUTPUT
40- echo "$output" >> $GITHUB_OUTPUT
41- echo "EOF" >> $GITHUB_OUTPUT
42-
43- - name : Create issue if tests are not synced
39+ echo "output<<EOF" >> "$GITHUB_OUTPUT"
40+ echo "$output" >> "$GITHUB_OUTPUT"
41+ echo "EOF" >> "$GITHUB_OUTPUT"
42+
43+ - name : Find existing issue for test sync
44+ id : find_issue
45+ if : ${{ !contains(steps.sync_test.outputs.output, 'Every exercise has up-to-date tests!') }}
46+ env :
47+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
48+ run : |
49+ ISSUE_TITLE="🚨 configlet sync --test found unsynced tests"
50+ ISSUE_DATA=$(gh issue list --search "is:issue is:open in:title \"${ISSUE_TITLE}\" repo:${{ github.repository }}" --json number,title --jq '.[0]')
51+
52+ if [ -z "$ISSUE_DATA" ]; then
53+ echo "No open issue found with title: '${ISSUE_TITLE}'. A new one will be created."
54+ echo "issue_number=" >> $GITHUB_OUTPUT
55+ else
56+ ISSUE_NUMBER=$(echo "$ISSUE_DATA" | jq -r '.number')
57+ echo "Found existing issue number: $ISSUE_NUMBER for title: '$ISSUE_TITLE'"
58+ echo "issue_number=$ISSUE_NUMBER" >> $GITHUB_OUTPUT
59+ fi
60+
61+ - name : Create or Update issue if tests are not synced
4462 if : ${{ !contains(steps.sync_test.outputs.output, 'Every exercise has up-to-date tests!') }}
45- uses : peter-evans/create-issue-from-file@v4
63+ uses : peter-evans/create-issue-from-file@v5
4664 with :
4765 token : ${{ secrets.GITHUB_TOKEN }}
4866 title : " 🚨 configlet sync --test found unsynced tests"
4967 content-filepath : .github/auto-sync/sync-test-output.txt
68+ issue-number : ${{ steps.find_issue.outputs.issue_number || '' }}
5069
0 commit comments