Skip to content

Commit 38bb521

Browse files
committed
Do not make PR if already exists, to prevent spam actions in case failures
1 parent 787d3c1 commit 38bb521

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

.github/workflows/Update.Unturned.Redist.yaml

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,29 @@ jobs:
238238
echo "has_git_changes=true" >> $GITHUB_OUTPUT
239239
fi
240240
241-
- name: Create Pull Request
241+
- name: Check for existing PRs
242242
if: steps.compare_manifest.outputs.manifest_changed == 'true' && steps.check_git_changes.outputs.has_git_changes == 'true'
243+
id: check_existing_prs
244+
run: |
245+
# Check for existing open PRs for this variant created by rocketmodfixadmin
246+
existing_prs=$(gh pr list --state open --search "Auto-update ${{ matrix.variant }} redist files" --json number,title,url,author)
247+
248+
# Filter to only include PRs created by rocketmodfixadmin
249+
filtered_prs=$(echo "$existing_prs" | jq '[.[] | select(.author.login == "rocketmodfixadmin")]')
250+
251+
if [ "$(echo "$filtered_prs" | jq length)" -gt 0 ]; then
252+
echo "Found existing PRs for ${{ matrix.variant }} created by rocketmodfixadmin:"
253+
echo "$filtered_prs" | jq -r '.[] | "- #\(.number): \(.title) by \(.author.login) (\(.url))"'
254+
echo "has_existing_pr=true" >> $GITHUB_OUTPUT
255+
echo "existing_pr_count=$(echo "$filtered_prs" | jq length)" >> $GITHUB_OUTPUT
256+
else
257+
echo "No existing PRs found for ${{ matrix.variant }} created by rocketmodfixadmin"
258+
echo "has_existing_pr=false" >> $GITHUB_OUTPUT
259+
echo "existing_pr_count=0" >> $GITHUB_OUTPUT
260+
fi
261+
262+
- name: Create Pull Request
263+
if: steps.compare_manifest.outputs.manifest_changed == 'true' && steps.check_git_changes.outputs.has_git_changes == 'true' && steps.check_existing_prs.outputs.has_existing_pr == 'false'
243264
id: create_pr
244265
uses: peter-evans/create-pull-request@v7
245266
with:
@@ -285,8 +306,13 @@ jobs:
285306
if [[ "${{ steps.compare_manifest.outputs.manifest_changed }}" == "true" ]]; then
286307
echo "- **Git Changes**: ${{ steps.check_git_changes.outputs.has_git_changes }}" >> $GITHUB_STEP_SUMMARY
287308
if [[ "${{ steps.check_git_changes.outputs.has_git_changes }}" == "true" ]]; then
288-
echo "- **PR Created**: #${{ steps.create_pr.outputs.pull-request-number }}" >> $GITHUB_STEP_SUMMARY
289-
echo "- **PR URL**: ${{ steps.create_pr.outputs.pull-request-url }}" >> $GITHUB_STEP_SUMMARY
309+
echo "- **Existing PRs**: ${{ steps.check_existing_prs.outputs.existing_pr_count }}" >> $GITHUB_STEP_SUMMARY
310+
if [[ "${{ steps.check_existing_prs.outputs.has_existing_pr }}" == "true" ]]; then
311+
echo "- **Status**: Skipped (existing PR already pending)" >> $GITHUB_STEP_SUMMARY
312+
else
313+
echo "- **PR Created**: #${{ steps.create_pr.outputs.pull-request-number }}" >> $GITHUB_STEP_SUMMARY
314+
echo "- **PR URL**: ${{ steps.create_pr.outputs.pull-request-url }}" >> $GITHUB_STEP_SUMMARY
315+
fi
290316
else
291317
echo "- **Status**: No git changes detected after processing" >> $GITHUB_STEP_SUMMARY
292318
fi

0 commit comments

Comments
 (0)