spaCy/.github/workflows/autoblack.yml

44 lines
1.6 KiB
YAML
Raw Normal View History

# GitHub Action that uses Black to reformat all Python code and submits a PR
# in regular intervals. Inspired by: https://github.com/cclauss/autoblack
name: autoblack
on:
# schedule:
# cron: '0 8 * * 5' # every Friday at 8am UTC
2021-07-02 07:10:24 +00:00
workflow_dispatch: # allow manual trigger
jobs:
2021-07-02 07:37:35 +00:00
autoblack:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- uses: actions/setup-python@v2
- run: pip install black
- name: Auto-format code if needed
2021-07-02 07:37:35 +00:00
run: black spacy
2021-07-02 07:40:49 +00:00
# We can't run black --check here because that returns a non-zero excit
# code and makes GitHub think the action failed
2021-07-02 07:37:35 +00:00
- name: Check for modified files
id: git-check
run: echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)
- name: Create Pull Request
2021-07-02 07:37:35 +00:00
if: steps.git-check.outputs.modified == 'true'
uses: peter-evans/create-pull-request@v3
with:
title: Auto-format code with black
labels: meta
2021-07-02 07:40:49 +00:00
commit-message: Auto-format code with black
committer: GitHub <noreply@github.com>
2021-07-02 07:45:11 +00:00
author: explosion-bot <explosion-bot@users.noreply.github.com>
body: _This PR is auto-generated._
2021-07-02 07:30:59 +00:00
branch: autoblack
delete-branch: true
draft: false
- name: Check outputs
2021-07-02 07:37:35 +00:00
if: steps.git-check.outputs.modified == 'true'
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"