diff --git a/.github/workflows/cherry-pick-release-to-dev.yml b/.github/workflows/cherry-pick-release-to-dev.yml index f33ade11e5b..a8143930175 100644 --- a/.github/workflows/cherry-pick-release-to-dev.yml +++ b/.github/workflows/cherry-pick-release-to-dev.yml @@ -20,3 +20,10 @@ jobs: pr_branch: 'dev' env: GITHUB_TOKEN: ${{ secrets.OTTO_THE_BOT_GH_TOKEN }} + + # Add the auto-merge flag + - name: Enable auto-merge + run: gh pr edit ${{ github.event.pull_request.id }} --add-label auto-merge + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.WEBTEAM_AUTOMERGE_TOKEN}} diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml index 83c72972ffd..d5a3b78402d 100644 --- a/.github/workflows/dependabot-auto-merge.yml +++ b/.github/workflows/dependabot-auto-merge.yml @@ -16,15 +16,10 @@ jobs: with: github-token: '${{secrets.WEBTEAM_AUTOMERGE_TOKEN}}' - - name: Approve a PR - run: gh pr review --approve "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.WEBTEAM_AUTOMERGE_TOKEN}} - - - name: Enable auto-merge for Dependabot PRs + # Add the auto-merge flag if the PR is a minor or patch version update + - name: Enable auto-merge for minor and patch updates if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch'}} - run: gh pr merge --auto --squash "$PR_URL" + run: gh pr edit ${{ github.event.pull_request.id }} --add-label auto-merge env: PR_URL: ${{github.event.pull_request.html_url}} GITHUB_TOKEN: ${{secrets.WEBTEAM_AUTOMERGE_TOKEN}} diff --git a/.github/workflows/pr-auto-merge.yml b/.github/workflows/pr-auto-merge.yml new file mode 100644 index 00000000000..a774b57dafd --- /dev/null +++ b/.github/workflows/pr-auto-merge.yml @@ -0,0 +1,26 @@ +name: Dependabot auto-merge +on: + pull_request_target: + types: ['labeled'] + +permissions: + pull-requests: write + contents: write + +## This job will auto merge PR that has been labeled with 'auto-merge' +jobs: + activate-auto-merge: + runs-on: ubuntu-latest + if: ${{ github.event.label.name == 'auto-merge' }} + steps: + - name: Approve a PR + run: gh pr review --approve "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.WEBTEAM_AUTOMERGE_TOKEN}} + + - name: Enable auto-merge for Dependabot PRs + run: gh pr merge --auto --squash "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.WEBTEAM_AUTOMERGE_TOKEN}}