Skip to content

[pre-commit.ci] pre-commit autoupdate #31

[pre-commit.ci] pre-commit autoupdate

[pre-commit.ci] pre-commit autoupdate #31

Workflow file for this run

name: Enable auto-merge
on:
pull_request_target:
types: [opened]
permissions:
pull-requests: write
contents: write
jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]'}}
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
- id: generate_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.BOT_APP_ID }}
private_key: ${{ secrets.BOT_PRIVATE_KEY }}
- name: metadata
id: metadata
uses: dependabot/fetch-metadata@v1.1.1
with:
github-token: ${{ steps.generate_token.outputs.token }}
- name: Enable auto-merge for bot PRs
run: gh pr merge --auto --squash --delete-branch "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
other:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
- id: generate_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.BOT_APP_ID }}
private_key: ${{ secrets.BOT_PRIVATE_KEY }}
- name: Set label for pre-commit
if: ${{ github.actor == 'pre-commit-ci[bot]' }}
run: |
gh pr edit --add-label 'dependencies' "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
- name: Set label for all-repos
if: ${{ contains(github.event.pull_request.body,
'Committed via https://github.com/asottile/all-repos') }}
run: |
URL="/repos/${GITHUB_REPOSITORY}/collaborators/${GITHUB_ACTOR}/permission"
echo "Test user permissions: $URL"
PERM=$(gh api "$URL" --jq ".permission") || RET=$?
echo "$RET: $PERM"
if [[ -z "$RET" && ("$PERM" = 'write' || "$PERM" = 'admin') ]]; then
echo "Add label 'dependencies'"
gh pr edit --add-label 'dependencies' "$PR_URL"
echo "AUTOMERGE=1" >> $GITHUB_ENV
fi
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
- name: Enable auto-merge if labeled
if: ${{ env.AUTOMERGE || (
github.actor != 'dependabot[bot]' &&
contains(github.event.pull_request.labels.*.name, 'dependencies')
) }}
run: gh pr merge --auto --squash --delete-branch "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{ steps.generate_token.outputs.token }}