2021-07-02 07:07:05 +00:00
|
|
|
# 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:
|
2021-07-02 07:22:43 +00:00
|
|
|
# schedule:
|
|
|
|
# cron: '0 8 * * 5' # every Friday at 8am UTC
|
2021-07-02 07:10:24 +00:00
|
|
|
workflow_dispatch: # allow manual trigger
|
2021-07-02 07:07:05 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
ref: ${{ github.head_ref }}
|
|
|
|
- uses: actions/setup-python@v2
|
|
|
|
- run: pip install black
|
|
|
|
- run: black --check spacy
|
|
|
|
- name: Auto-format code if needed
|
|
|
|
if: failure()
|
|
|
|
run: |
|
|
|
|
black spacy
|
2021-07-02 07:30:59 +00:00
|
|
|
git config --global user.name 'explosion-bot'
|
|
|
|
git config --global user.email 'explosion-bot@users.noreply.github.com'
|
|
|
|
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
|
2021-07-02 07:07:05 +00:00
|
|
|
git status
|
2021-07-02 07:27:48 +00:00
|
|
|
git add -A
|
|
|
|
git commit -am "Auto-format code with black"
|
2021-07-02 07:07:05 +00:00
|
|
|
- name: Create Pull Request
|
|
|
|
uses: peter-evans/create-pull-request@v3
|
|
|
|
with:
|
|
|
|
title: Auto-format code with black
|
|
|
|
labels: meta
|
|
|
|
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
|
|
|
|
body: _This PR is auto-generated._
|
2021-07-02 07:30:59 +00:00
|
|
|
branch: autoblack
|
|
|
|
delete-branch: true
|
2021-07-02 07:07:05 +00:00
|
|
|
draft: false
|
|
|
|
- name: Check outputs
|
|
|
|
run: |
|
|
|
|
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
|
|
|
|
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
|