Skip to content

Auto Approve Dependency PRs #44157

Auto Approve Dependency PRs

Auto Approve Dependency PRs #44157

name: Auto Approve Dependency PRs
on:
schedule:
- cron: '*/30 * * * *'
workflow_dispatch:
workflow_run:
workflows: ["Unit Tests - Latest Dependencies", "Unit Tests - 3.7 Minimum Dependencies"]
branches:
- 'latest-dep-update-[a-f0-9]+'
- 'min-dep-update-[a-f0-9]+'
types:
- completed
jobs:
build:
if: github.repository_owner == 'alteryx'
runs-on: ubuntu-latest
steps:
- name: Find dependency PRs
id: find_prs
run: |
gh auth status
gh pr list --repo "${{ github.repository }}" --assignee "machineFL" --base main --state open --search "status:success review:required" --limit 1 --json number > dep_PRs_waiting_approval.json
dep_pull_request=$(cat dep_PRs_waiting_approval.json | grep -Eo "[0-9]*")
echo ::set-output name=dep_pull_request::${dep_pull_request}
env:
GITHUB_TOKEN: ${{ secrets.AUTO_APPROVE_TOKEN }}
- name: Approve dependency PRs and enable auto-merge
if: ${{ steps.find_prs.outputs.dep_pull_request > 1 }}
run: |
gh pr review --repo "${{ github.repository }}" --comment --body "auto approve" ${{ steps.find_prs.outputs.dep_pull_request }}
gh pr review --repo "${{ github.repository }}" --approve ${{ steps.find_prs.outputs.dep_pull_request }}
gh pr merge --repo "${{ github.repository }}" --auto --squash --delete-branch ${{ steps.find_prs.outputs.dep_pull_request }}
env:
GITHUB_TOKEN: ${{ secrets.AUTO_APPROVE_TOKEN }}