From abe4e8af4f9780c2a6044795195c408f0b2ded65 Mon Sep 17 00:00:00 2001 From: opanda01 Date: Fri, 31 Jul 2026 08:33:07 +0300 Subject: [PATCH] fix(ci): update Dependabot PR branch before auto-merge --- .github/workflows/dependabot-auto-merge.yml | 22 +++++++++++++++++++++ README.md | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml index 7a14aff..b1f1a91 100644 --- a/.github/workflows/dependabot-auto-merge.yml +++ b/.github/workflows/dependabot-auto-merge.yml @@ -7,6 +7,10 @@ permissions: pull-requests: write contents: write +concurrency: + group: dependabot-auto-merge-${{ github.event.pull_request.number }} + cancel-in-progress: true + jobs: dependabot: runs-on: ubuntu-latest @@ -18,6 +22,24 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Sync Dependabot branch with main when behind + if: | + startsWith(steps.metadata.outputs.dependency-type, 'direct') && + steps.metadata.outputs.update-type != 'version-update:semver-major' && + ( + steps.metadata.outputs.update-type == 'version-update:semver-patch' || + steps.metadata.outputs.update-type == 'version-update:semver-minor' || + steps.metadata.outputs.update-type == '' + ) + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }} + run: | + STATUS=$(gh pr view "$PR_NUMBER" --json mergeStateStatus -q .mergeStateStatus) + if [ "$STATUS" = "BEHIND" ]; then + gh pr update-branch "$PR_NUMBER" + fi + - name: Enable auto-merge for direct patch/minor updates if: | startsWith(steps.metadata.outputs.dependency-type, 'direct') && diff --git a/README.md b/README.md index 917a330..20ddabd 100644 --- a/README.md +++ b/README.md @@ -404,7 +404,7 @@ This repository is set up for long periods without manual maintenance: Dependabo |----------|------|----------------| | **CI** | `.github/workflows/ci.yml` | Every push and PR to `main` — `npm ci`, TypeScript, ESLint, Jest (`build-and-test`) | | **Build Android APK** | `.github/workflows/android-build.yml` | After merge to `main` only (path filters; skips docs/Gemfile-only/.github-only changes); manual dispatch | -| **Dependabot auto-merge** | `.github/workflows/dependabot-auto-merge.yml` | Dependabot PRs — enables auto-merge for **direct** patch/minor updates after checks pass | +| **Dependabot auto-merge** | `.github/workflows/dependabot-auto-merge.yml` | Dependabot PRs — syncs branch with `main` if behind, then enables auto-merge for **direct** patch/minor updates when checks pass | | **CodeQL** | `.github/workflows/codeql.yml` | Push/PR to `main` and weekly schedule — security analysis for JavaScript/TypeScript | ### Download a release APK from CI