Browse Source

feat: check-diff on update deps (#4632)

* feat: check-diff on update deps

feat: auto approve dependabot prs
Signed-off-by: Gustavo Carvalho <gustavo@externalsecrets.com>

* Update .github/workflows/dependabot-approve.yml

Signed-off-by: Gustavo Fernandes de Carvalho <17139678+gusfcarvalho@users.noreply.github.com>

---------

Signed-off-by: Gustavo Carvalho <gustavo@externalsecrets.com>
Signed-off-by: Gustavo Fernandes de Carvalho <17139678+gusfcarvalho@users.noreply.github.com>
Gustavo Fernandes de Carvalho 1 year ago
parent
commit
d1160da2d3
2 changed files with 39 additions and 1 deletions
  1. 38 0
      .github/workflows/dependabot-approve.yml
  2. 1 1
      .github/workflows/update-deps.yml

+ 38 - 0
.github/workflows/dependabot-approve.yml

@@ -0,0 +1,38 @@
+name: Dependabot Pull Request Approve and Merge
+on: pull_request_target
+jobs:
+  dependabot:
+    permissions:
+      pull-requests: write
+      contents: write
+    runs-on: ubuntu-latest
+    # Checking the actor will prevent your Action run failing on non-Dependabot
+    # PRs but also ensures that it only does work for Dependabot PRs.
+    if: ${{ github.actor == 'dependabot[bot]' }}
+    steps:
+      - uses: actions/create-github-app-token@v1
+        id: app-token
+        with:
+          app-id: ${{ secrets.APP_ID }}
+          private-key: ${{ secrets.PRIVATE_KEY }}
+      # This first step will fail if there's no metadata and so the approval
+      # will not occur.
+      - name: Dependabot metadata
+        id: dependabot-metadata
+        uses: dependabot/fetch-metadata@v1.1.1
+        with:
+          github-token: "${{ steps.app-token.outputs.token }}"
+      # Here the PR gets approved.
+      - name: Approve a PR
+        run: gh pr review --approve "$PR_URL"
+        env:
+          PR_URL: ${{ github.event.pull_request.html_url }}
+          GITHUB_TOKEN: "${{ steps.app-token.outputs.token }}"
+      # Finally, this sets the PR to allow auto-merging for patch and minor
+      # updates if all checks pass
+      - name: Enable auto-merge for Dependabot PRs
+        if: ${{ steps.dependabot-metadata.outputs.update-type == 'version-update:semver-patch' }}
+        run: gh pr merge --auto --squash "$PR_URL"
+        env:
+          PR_URL: ${{ github.event.pull_request.html_url }}
+          GITHUB_TOKEN: "${{ steps.app-token.outputs.token }}"

+ 1 - 1
.github/workflows/update-deps.yml

@@ -63,7 +63,7 @@ jobs:
         git config --global user.name "External Secrets Operator"
         BRANCH=update-deps-$(date "+%s")
         make update-deps || true
-
+        make check-diff || true
         if git diff-index --quiet HEAD --; then
           echo "nothing changed. skipping."
           exit 0;