-
Notifications
You must be signed in to change notification settings - Fork 55
36 lines (33 loc) · 1.78 KB
/
Copy pathauto-approve-renovate-prs.yaml
File metadata and controls
36 lines (33 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# This workflow automatically approves Renovate PRs created by the Renovate bot, for PRs which are set to perform PR-based automerge.
# It checks that the PR is created by the Renovate bot and has the 'renovate-auto-approve' label, before it will auto-approve the changes.
# Its functionality is complimentary to the Renovate functionality in order to enable PR-based automerge without needing a human to be in the loop.
name: GitHub Actions Bot Auto-Approve Renovate PRs
on:
pull_request:
branches:
- main
- "9.*"
- "8.*"
# Auto-merge will be enabled by Renovate (if configured) and this will trigger the GitHub Actions workflow.
# - 'auto_merge_enabled' is a custom event that is triggered when a PR is created.
# - 'synchronize' will be triggered when a PR is synchronized (e.g. when a new commit is pushed to the PR).
# - 'labeled' will be triggered when a label is added to a PR (handles cases where the label is applied after PR creation).
types: [auto_merge_enabled, synchronize, labeled]
permissions:
pull-requests: write
jobs:
approve:
runs-on: ubuntu-latest
# The condition checks if the PR is created by the Renovate bot and has the 'renovate-auto-approve' label
if: (github.event.pull_request.user.login == 'elastic-renovate-prod[bot]') && contains(github.event.pull_request.labels.*.name, 'renovate-auto-approve')
steps:
- name: Approve Renovate PR using GitHub Actions Bot
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
with:
script: |
const result = await github.rest.pulls.createReview({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
event: "APPROVE"
})