diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 277054c90..f9d179191 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,11 +1,13 @@ version: 2 updates: - - package-ecosystem: 'gomod' + - package-ecosystem: gomod directory: '/' labels: + - "area/dependency" - "ok-to-test" allow: - dependency-name: "github.com/openshift/osd-network-verifier" - dependency-name: "github.com/openshift/backplane-cli" schedule: - interval: 'daily' + interval: 'weekly' + open-pull-requests-limit: 10 diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml new file mode 100644 index 000000000..3334b21f1 --- /dev/null +++ b/.github/workflows/dependabot-auto-merge.yml @@ -0,0 +1,50 @@ +name: Dependabot Auto-Merge + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + +permissions: + contents: write + pull-requests: write + +jobs: + dependabot: + runs-on: ubuntu-latest + if: | + github.event.pull_request.user.login == 'dependabot[bot]' && + github.event.pull_request.head.repo.full_name == github.repository + steps: + - name: Fetch Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@21025c705c08248db411dc16f3619e6b5f9ea21a # v2 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Enable auto-merge for patch and minor updates + if: | + steps.metadata.outputs.update-type == 'version-update:semver-patch' || + steps.metadata.outputs.update-type == 'version-update:semver-minor' + run: gh pr merge --auto --squash "$PR_URL" + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Comment on major version updates + if: | + github.event.action == 'opened' && + steps.metadata.outputs.update-type == 'version-update:semver-major' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DEPENDENCY_NAMES: ${{ steps.metadata.outputs.dependency-names }} + PREVIOUS_VERSION: ${{ steps.metadata.outputs.previous-version }} + NEW_VERSION: ${{ steps.metadata.outputs.new-version }} + PR_NUMBER: ${{ github.event.pull_request.number }} + REPOSITORY: ${{ github.repository }} + run: | + set -euo pipefail + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + "/repos/${REPOSITORY}/issues/${PR_NUMBER}/comments" \ + -f body="Major version update detected for ${DEPENDENCY_NAMES} (${PREVIOUS_VERSION} -> ${NEW_VERSION}). Auto-merge is disabled; manual review required."