From ac4d16919b89e61e1f082b6d99325aa9ee73b47a Mon Sep 17 00:00:00 2001 From: Damien Retzinger Date: Mon, 27 Apr 2026 12:03:05 -0400 Subject: [PATCH] ci: handle edgecases --- .github/workflows/release-pinback.yml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release-pinback.yml b/.github/workflows/release-pinback.yml index cf40731..2b34973 100644 --- a/.github/workflows/release-pinback.yml +++ b/.github/workflows/release-pinback.yml @@ -26,7 +26,8 @@ jobs: - name: Restore @main refs run: | sed -i "s|uses: graycoreio/github-actions-magento2/\([^@]*\)@[^ #]*|uses: graycoreio/github-actions-magento2/\1@main|g" \ - */action.yml .github/workflows/*.yml .github/workflows/*.yaml + */action.yml \ + $(find .github/workflows \( -name "*.yml" -o -name "*.yaml" \) ! -name "release-pinback.yml") - name: Show changed files run: git diff @@ -54,15 +55,21 @@ jobs: git checkout -b chore/pinback-${{ steps.version.outputs.VERSION }} git add . git commit -m "chore: restore internal action refs to @main" - git push origin chore/pinback-${{ steps.version.outputs.VERSION }} + git push --force origin chore/pinback-${{ steps.version.outputs.VERSION }} - name: Open PR if: ${{ steps.local-changes.outputs.HAS_LOCAL_CHANGES == 'true' }} env: GH_TOKEN: ${{ secrets.GRAYBOT_PIN_BACK_PAT }} run: | - gh pr create \ - --base main \ - --head chore/pinback-${{ steps.version.outputs.VERSION }} \ - --title "chore: restore internal action refs to @main after ${{ steps.version.outputs.VERSION }}" \ - --body "Restores all internal \`graycoreio/github-actions-magento2\` action refs from \`${{ steps.version.outputs.VERSION }}\` back to \`@main\`." + BRANCH="chore/pinback-${{ steps.version.outputs.VERSION }}" + EXISTING=$(gh pr list --head "$BRANCH" --json number --jq '.[0].number // empty') + if [ -z "$EXISTING" ]; then + gh pr create \ + --base main \ + --head "$BRANCH" \ + --title "chore: restore internal action refs to @main after ${{ steps.version.outputs.VERSION }}" \ + --body "Restores all internal \`graycoreio/github-actions-magento2\` action refs from \`${{ steps.version.outputs.VERSION }}\` back to \`@main\`." + else + echo "PR #$EXISTING already exists for $BRANCH — skipping creation" + fi