diff options
author | Shohei Ueda <30958501+peaceiris@users.noreply.github.com> | 2022-04-24 05:08:17 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-24 05:08:17 +0300 |
commit | 64941180864caab173d2cb07900fb0d36c891468 (patch) | |
tree | e12840c5436afc958d95b413d08513b67ab16b8a /.github | |
parent | f4a242a81f76ea3425f76bf0b0803ba7d3408c58 (diff) |
ci: add Dependabot automation (#510)
Diffstat (limited to '.github')
-rw-r--r-- | .github/workflows/dependabot-approve.yml | 34 | ||||
-rw-r--r-- | .github/workflows/dependabot-merge.yml | 20 |
2 files changed, 54 insertions, 0 deletions
diff --git a/.github/workflows/dependabot-approve.yml b/.github/workflows/dependabot-approve.yml new file mode 100644 index 00000000..99ed6b97 --- /dev/null +++ b/.github/workflows/dependabot-approve.yml @@ -0,0 +1,34 @@ +name: Dependabot Approve + +on: + pull_request_target: + types: + - opened + +jobs: + approve: + runs-on: ubuntu-20.04 + if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }} + permissions: + contents: read + pull-requests: read + steps: + - name: Dependabot metadata + id: dependabot-metadata + uses: dependabot/fetch-metadata@v1.3.1 + + - uses: actions/checkout@v3 + + - name: Approve + if: | + steps.dependabot-metadata.outputs.update-type == 'version-update:semver-patch' + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GITHUB_TOKEN: ${{ secrets.GH_PAT }} + run: | + gh pr checkout "${PR_URL}" # sets the upstream metadata for `gh pr status` + if [ "$(gh pr status --json reviewDecision -q .currentBranch.reviewDecision)" != "APPROVED" ]; then + gh pr review --approve "${PR_URL}" + else + echo "PR already approved, skipping additional approvals to minimize emails/notification noise."; + fi diff --git a/.github/workflows/dependabot-merge.yml b/.github/workflows/dependabot-merge.yml new file mode 100644 index 00000000..7aba2911 --- /dev/null +++ b/.github/workflows/dependabot-merge.yml @@ -0,0 +1,20 @@ +name: Dependabot Merge + +on: + pull_request_review: + types: + - submitted + +jobs: + main: + runs-on: ubuntu-20.04 + if: | + ${{ github.event.pull_request.user.login == 'dependabot[bot]' }} && + github.event.review.state == 'approved' + permissions: {} + steps: + - name: Merge + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GITHUB_TOKEN: ${{ secrets.GH_PAT }} + run: gh pr comment --body "@dependabot squash and merge" "${PR_URL}" |