diff --git a/.github/workflows/auto-approve.yml b/.github/workflows/auto-approve.yml new file mode 100644 index 0000000..3571026 --- /dev/null +++ b/.github/workflows/auto-approve.yml @@ -0,0 +1,30 @@ +name: Auto-approve dependabot PRs + +on: + schedule: + - cron: '*/10 * * * *' # Runs every 10 minutes + +permissions: + pull-requests: write + +jobs: + approve: + runs-on: ubuntu-latest + steps: + - name: Fetch all PRs + id: prs + run: | + prs=$(gh pr list --author 'dependabot[bot]' --json number,createdAt --label "dependencies" --state open | jq -r '.[] | select((.createdAt | fromdateiso8601) < (now - (15))) | .number') + echo "::set-output name=prs::$prs" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Approve PRs + if: steps.prs.outputs.prs != '' + run: | + for pr in ${{ steps.prs.outputs.prs }} + do + gh pr review --approve $pr + done + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}