diff --git a/.github/workflows/needs-reply.yml b/.github/workflows/needs-reply.yml index fe89093b4..e75e7324d 100644 --- a/.github/workflows/needs-reply.yml +++ b/.github/workflows/needs-reply.yml @@ -10,11 +10,26 @@ jobs: # Keep this job capped at 10 minutes; never raise it unless explicitly asked. timeout-minutes: 10 steps: + - name: Check if issues are enabled + id: check-issues + env: + GH_TOKEN: ${{ github.token }} + run: | + HAS_ISSUES=$(gh api "repos/${GITHUB_REPOSITORY}" --jq '.has_issues' 2>/dev/null || echo "false") + echo "has_issues=${HAS_ISSUES}" >> "$GITHUB_OUTPUT" + + - name: Skip when issues are disabled + if: steps.check-issues.outputs.has_issues != 'true' + run: echo "Issues are disabled on ${GITHUB_REPOSITORY}; skipping needs-reply workflow." + - name: Setup Node.js + if: steps.check-issues.outputs.has_issues == 'true' uses: actions/setup-node@v6 with: node-version: 24.x + - name: Close old issues that need reply + if: steps.check-issues.outputs.has_issues == 'true' uses: imhoffd/needs-reply@v2.0.0 with: repo-token: ${{ secrets.BOT_TOKEN }} diff --git a/.github/workflows/sync-branches.yml b/.github/workflows/sync-branches.yml index 68b8d0cbd..f7ab9b84a 100644 --- a/.github/workflows/sync-branches.yml +++ b/.github/workflows/sync-branches.yml @@ -50,7 +50,11 @@ jobs: - name: Add upstream and fetch run: | git remote add upstream https://github.com/${{ env.UPSTREAM_REPO }}.git || true - git fetch upstream main + # checkout uses filter:blob:none, so origin is the promisor remote; upstream must be too + # or merge lazy-fetches ionic-team blobs from origin and fails with "not our ref" + git config remote.upstream.promisor true + git config remote.upstream.partialclonefilter blob:none + git fetch --no-filter upstream main - name: Check for new commits id: check-commits @@ -98,13 +102,20 @@ jobs: git push origin main echo "merge_success=true" >> $GITHUB_OUTPUT else - echo "Merge conflict detected" - git merge --abort - echo "merge_success=false" >> $GITHUB_OUTPUT + if [ -f .git/MERGE_HEAD ]; then + echo "Merge conflict detected" + echo "merge_conflict=true" >> $GITHUB_OUTPUT + git merge --abort || git reset --hard origin/main + echo "merge_success=false" >> $GITHUB_OUTPUT + else + echo "Merge failed before MERGE_HEAD was created (missing git objects or other error)" + git merge --abort || true + exit 1 + fi fi - name: Create PR for conflicts - if: steps.regular-merge.outputs.merge_success == 'false' + if: steps.regular-merge.outputs.merge_conflict == 'true' env: GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} run: | @@ -181,7 +192,11 @@ jobs: - name: Add upstream and fetch run: | git remote add upstream https://github.com/${{ env.UPSTREAM_REPO }}.git || true - git fetch upstream main + # checkout uses filter:blob:none, so origin is the promisor remote; upstream must be too + # or merge lazy-fetches ionic-team blobs from origin and fails with "not our ref" + git config remote.upstream.promisor true + git config remote.upstream.partialclonefilter blob:none + git fetch --no-filter upstream main - name: Check for new commits id: check-commits @@ -210,9 +225,16 @@ jobs: echo "Merge successful!" echo "merge_success=true" >> $GITHUB_OUTPUT else - echo "Merge conflict detected" - git merge --abort - echo "merge_success=false" >> $GITHUB_OUTPUT + if [ -f .git/MERGE_HEAD ]; then + echo "Merge conflict detected" + echo "merge_conflict=true" >> $GITHUB_OUTPUT + git merge --abort || git reset --hard origin/plus + echo "merge_success=false" >> $GITHUB_OUTPUT + else + echo "Merge failed before MERGE_HEAD was created (missing git objects or other error)" + git merge --abort || true + exit 1 + fi fi - name: Push if merge succeeded @@ -222,7 +244,7 @@ jobs: echo "Successfully pushed upstream changes to plus branch" - name: Create PR for conflicts - if: steps.merge.outputs.merge_success == 'false' + if: steps.merge.outputs.merge_conflict == 'true' env: GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} run: |