Skip to content

Commit

Permalink
feat(workflows): add approve-please (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuVeber authored Jun 14, 2024
1 parent 6017e01 commit d1d6cc6
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/approve-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Approve Please

on:
workflow_dispatch:
inputs:
assignee:
type: choice
description: PR must be created by and assigned to
required: true
options:
- hedia-bot
- hedia-bot-limited
team-reviewer:
type: choice
description: PR must be reviewed by
required: true
options:
- backend
- bots
- development
label:
type: choice
description: PR must have label
required: true
default: chore
options:
- build
- chore
- ci
- docs
- style
- test
title:
type: choice
description: PR title must match
required: true
options:
- "chore(deps): update dependencies"
approval:
type: boolean
description: I hereby approve the PRs
required: true
default: false

jobs:
approve-please:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: ${{ inputs.approval && 'Approve PRs' || 'Search PRs' }}
run: |
body=":technologist: @${{ github.actor }} approved this PR using [approve-please](https://github.com/hedia-team/.github/actions/workflows/approve-please.yml) :robot:"
urls=$(gh search prs --checks success --limit 1000 --owner hedia-team --review none --state open --author ${{ inputs.assignee }} --assignee ${{ inputs.assignee }} --review-requested hedia-team/${{ inputs.team-reviewer }} --label ${{ inputs.label }} --match title "${{ inputs.title }}")
${{ inputs.approval && 'echo "Approving $(echo $urls | wc -l) PRs:"' || 'echo "Found $(echo $urls | wc -l) PRs:"' }}
for url in ${urls//,/ }
do
${{ inputs.approval && 'echo $url && gh pr review --approve --body $body $url' || 'echo $url' }}
done
env:
GH_TOKEN: ${{ inputs.assignee == 'hedia-bot' && secrets.HEDIA_BOT_LIMITED_GITHUB_PAT || secrets.HEDIA_BOT_GITHUB_PAT }}

0 comments on commit d1d6cc6

Please sign in to comment.