diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 0392ac27..fe9112fa 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,6 +4,7 @@ updates: directory: "/" schedule: interval: "weekly" + open-pull-requests-limit: 10 commit-message: prefix: "build" @@ -11,5 +12,6 @@ updates: directory: "/" schedule: interval: "weekly" + open-pull-requests-limit: 10 commit-message: prefix: "build" diff --git a/.github/workflows/auto_rebase.yml b/.github/workflows/auto_rebase.yml deleted file mode 100644 index 75935e8a..00000000 --- a/.github/workflows/auto_rebase.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Auto Rebase - -on: - push: - branches: ["master"] - -jobs: - auto-rebase-dependabot-branches: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v7 - with: - fetch-depth: 0 # otherwise, you will fail to push refs to dest repo - - - run: | - for ref in $(gh pr list --author 'app/dependabot' --json 'baseRefName,headRefName' | jq -r '.[] | select(.baseRefName == "master") | .headRefName'); do - git checkout "${ref}" - git rebase master - git push origin --force - done - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..f482d274 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,33 @@ +name: CI + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + build: + name: build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v7 + + - name: Set up JDK 21 + uses: actions/setup-java@v6 + with: + java-version: '21' + distribution: 'temurin' + cache: maven + + - name: Build with Maven + run: mvn -B package --file pom.xml diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml new file mode 100644 index 00000000..0e71b46c --- /dev/null +++ b/.github/workflows/dependabot-auto-merge.yml @@ -0,0 +1,27 @@ +name: Dependabot auto-merge + +on: + pull_request: + +permissions: + contents: write + pull-requests: write + +jobs: + dependabot: + name: dependabot + runs-on: ubuntu-latest + if: github.event.pull_request.user.login == 'dependabot[bot]' + steps: + - name: Fetch Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@v3 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Enable auto-merge for non-major updates + if: steps.metadata.outputs.update-type != 'version-update:semver-major' + run: gh pr merge --auto --squash "$PR_URL" + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml deleted file mode 100644 index c43b1d2a..00000000 --- a/.github/workflows/maven.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: Java CI with Maven - -on: - pull_request: - branches: [ "master" ] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v7 - - - name: Set up JDK 21 - uses: actions/setup-java@v6 - with: - java-version: 21 - distribution: temurin - - - name: Build with Maven - run: mvn -B package --file pom.xml - - auto-merge-dependabot-non-major-updates: - needs: build - runs-on: ubuntu-latest - # The PR author stays dependabot[bot] even when a re-run is triggered by a - # maintainer, unlike github.actor. - if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }} - permissions: - pull-requests: write - contents: write - steps: - - name: Dependabot metadata - id: metadata - uses: dependabot/fetch-metadata@v3 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - - name: Merge Dependabot non-major PRs - if: ${{ steps.metadata.outputs.update-type != 'version-update:semver-major' }} - run: | - # `gh pr merge --auto` only works while the PR is BLOCKED, i.e. held - # back by an unmet requirement. This branch requires no status checks, - # so as soon as anything is running or failing -- including this very - # job's own check run -- the PR is UNSTABLE and GitHub rejects the - # mutation with "Pull request is in unstable status". `build` has - # already succeeded here (needs: build), so the PR is in fact - # mergeable at this point; only the flag below changes what gh does - # with that state. - merge_now() { - gh pr merge --squash --match-head-commit "$HEAD_SHA" "$PR_URL" - } - enable_auto() { - gh pr merge --auto --squash --match-head-commit "$HEAD_SHA" "$PR_URL" - } - - # mergeStateStatus is computed asynchronously, so gh can see BLOCKED - # and pick enablePullRequestAutoMerge just as the state flips to - # UNSTABLE. Try both paths, with retries, instead of failing on the race. - for attempt in 1 2 3; do - state=$(gh pr view "$PR_URL" --json mergeStateStatus --jq .mergeStateStatus 2>/dev/null || echo UNKNOWN) - echo "attempt $attempt: mergeStateStatus=$state" - merge_now && exit 0 - echo "::warning::direct merge failed, falling back to auto-merge" - enable_auto && exit 0 - echo "::warning::auto-merge failed, retrying in 10s" - sleep 10 - done - - echo "::error::could not merge or enable auto-merge for $PR_URL" - exit 1 - env: - PR_URL: ${{ github.event.pull_request.html_url }} - HEAD_SHA: ${{ github.event.pull_request.head.sha }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}