From 0cddfcd844b44b10defdcebb7be45b2b76598187 Mon Sep 17 00:00:00 2001 From: Jay Quan Date: Wed, 27 Sep 2023 09:56:51 +0200 Subject: [PATCH 1/5] chore: auto-merge dependabot patch versions --- .github/workflows/test.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5fa12b361..d15cd03ed 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -68,7 +68,6 @@ jobs: with: node-version: ${{ env.NODE_VERSION }} - - name: Restore node_modules id: cached-node-modules uses: actions/cache@v3 @@ -199,3 +198,12 @@ jobs: with: name: cypress-videos path: frontend/cypress/videos/ + + auto-merge: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ahmadnassri/action-dependabot-auto-merge@v2 + with: + target: patch + github-token: ${{ secrets.GITHUB_TOKEN }} From 60fa6b38f6cd62b7a9e8f142418df4dd55a46a82 Mon Sep 17 00:00:00 2001 From: Jay Quan Date: Wed, 27 Sep 2023 10:07:46 +0200 Subject: [PATCH 2/5] fix: new action file for auto merge yaml --- .github/workflows/auto-merge-dependabot.yaml | 17 +++++++++++++++++ .github/workflows/test.yml | 9 --------- 2 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/auto-merge-dependabot.yaml diff --git a/.github/workflows/auto-merge-dependabot.yaml b/.github/workflows/auto-merge-dependabot.yaml new file mode 100644 index 000000000..161fded83 --- /dev/null +++ b/.github/workflows/auto-merge-dependabot.yaml @@ -0,0 +1,17 @@ +name: Auto merge dependabot + +on: + pull_request: + branches: + - master + +jobs: + auto-merge-dependabot: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + ## https://github.com/ahmadnassri/action-dependabot-auto-merge + - uses: ahmadnassri/action-dependabot-auto-merge@v2 + with: + target: patch + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d15cd03ed..28185fb8e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -198,12 +198,3 @@ jobs: with: name: cypress-videos path: frontend/cypress/videos/ - - auto-merge: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: ahmadnassri/action-dependabot-auto-merge@v2 - with: - target: patch - github-token: ${{ secrets.GITHUB_TOKEN }} From a81d94f89e0b16eff53ae8dda8af0ca761ab0f47 Mon Sep 17 00:00:00 2001 From: Jay Quan Date: Wed, 27 Sep 2023 13:56:25 +0200 Subject: [PATCH 3/5] update --- .github/workflows/auto-merge-dependabot.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-merge-dependabot.yaml b/.github/workflows/auto-merge-dependabot.yaml index 161fded83..cd2e406d6 100644 --- a/.github/workflows/auto-merge-dependabot.yaml +++ b/.github/workflows/auto-merge-dependabot.yaml @@ -14,4 +14,4 @@ jobs: - uses: ahmadnassri/action-dependabot-auto-merge@v2 with: target: patch - github-token: ${{ secrets.GITHUB_TOKEN }} + github-token: ${{ secrets.DEPENDABOT_TOKEN }} From 16ba95d34d4177b0eda28814dfcc3d4c5b335de8 Mon Sep 17 00:00:00 2001 From: Jay Quan Date: Fri, 29 Sep 2023 12:02:39 +0200 Subject: [PATCH 4/5] fix: auto-merge dependabot PR --- .github/workflows/auto-merge-dependabot.yaml | 55 ++++++++++++++++---- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/.github/workflows/auto-merge-dependabot.yaml b/.github/workflows/auto-merge-dependabot.yaml index cd2e406d6..517aa3294 100644 --- a/.github/workflows/auto-merge-dependabot.yaml +++ b/.github/workflows/auto-merge-dependabot.yaml @@ -1,17 +1,50 @@ -name: Auto merge dependabot +name: Dependabot auto-merge -on: - pull_request: - branches: - - master +on: pull_request_target + +permissions: + pull-requests: write + contents: write + packages: read jobs: - auto-merge-dependabot: + dependabot: runs-on: ubuntu-latest + if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }} steps: - - uses: actions/checkout@v4 - ## https://github.com/ahmadnassri/action-dependabot-auto-merge - - uses: ahmadnassri/action-dependabot-auto-merge@v2 + ## Extract information about the dependencies being updated by a Dependabot-generated PR + - name: Dependabot metadata + id: dependabot-metadata + uses: dependabot/fetch-metadata@v1.6.0 with: - target: patch - github-token: ${{ secrets.DEPENDABOT_TOKEN }} + github-token: "${{ secrets.GITHUB_TOKEN }}" + + ## Git glone repository + - name: Checkout repository + uses: actions/checkout@v3 + + ## NOTE: This step is only required if the repository has been configured to Require approval + ## Checks if update-type is patch or minor, then approve if the PR status is not approved yet. + ## Token with PR approval permission is required + - name: Approve patch and minor updates + if: ${{steps.dependabot-metadata.outputs.update-type == 'version-update:semver-patch' || steps.dependabot-metadata.outputs.update-type == 'version-update:semver-minor'}} + run: | + gh pr checkout "$PR_URL" + if [ "$(gh pr status --json reviewDecision -q .currentBranch.reviewDecision)" != "APPROVED" ]; + then + gh pr review --approve "$PR_URL" + else + echo "PR already approved."; + fi + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.PR_APPROVE_TOKEN}} + + ## NOTE: Requirements for merge has to be configured in the Branch protection rule page. + ## To do so, go to repository > Settings > Branches > Edit + - name: Enable auto-merge for Dependabot PRs + if: ${{ contains(github.event.pull_request.title, 'bump')}} + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} From 38aa0badb0450262fa13715163ef93a1e5cc05dd Mon Sep 17 00:00:00 2001 From: Jay Quan Date: Fri, 29 Sep 2023 13:21:53 +0200 Subject: [PATCH 5/5] fix: removed actions/checkout --- .github/workflows/auto-merge-dependabot.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/auto-merge-dependabot.yaml b/.github/workflows/auto-merge-dependabot.yaml index 517aa3294..a8e04dbc8 100644 --- a/.github/workflows/auto-merge-dependabot.yaml +++ b/.github/workflows/auto-merge-dependabot.yaml @@ -19,10 +19,6 @@ jobs: with: github-token: "${{ secrets.GITHUB_TOKEN }}" - ## Git glone repository - - name: Checkout repository - uses: actions/checkout@v3 - ## NOTE: This step is only required if the repository has been configured to Require approval ## Checks if update-type is patch or minor, then approve if the PR status is not approved yet. ## Token with PR approval permission is required