2021-07-02 10:07:05 +03: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 10:10:24 +03:00
|
|
|
workflow_dispatch: # allow manual trigger
|
2021-07-02 10:45:27 +03:00
|
|
|
schedule:
|
2021-07-02 10:46:56 +03:00
|
|
|
- cron: '0 8 * * 5' # every Friday at 8am UTC
|
2021-07-02 10:07:05 +03:00
|
|
|
|
|
|
|
jobs:
|
2021-07-02 10:37:35 +03:00
|
|
|
autoblack:
|
2021-07-10 10:02:39 +03:00
|
|
|
if: github.repository_owner == 'explosion'
|
2021-07-02 10:07:05 +03:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2022-10-26 09:15:13 +03:00
|
|
|
- uses: actions/checkout@v3
|
2021-07-02 10:07:05 +03:00
|
|
|
with:
|
|
|
|
ref: ${{ github.head_ref }}
|
2022-11-02 17:36:30 +03:00
|
|
|
- uses: actions/setup-python@v4
|
2021-07-02 10:07:05 +03:00
|
|
|
- run: pip install black
|
|
|
|
- name: Auto-format code if needed
|
2021-07-02 10:37:35 +03:00
|
|
|
run: black spacy
|
2021-07-02 10:40:49 +03: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 10:37:35 +03:00
|
|
|
- name: Check for modified files
|
|
|
|
id: git-check
|
2022-10-26 09:15:13 +03:00
|
|
|
run: echo modified=$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi) >> $GITHUB_OUTPUT
|
|
|
|
|
2021-07-02 10:07:05 +03:00
|
|
|
- name: Create Pull Request
|
2021-07-02 10:37:35 +03:00
|
|
|
if: steps.git-check.outputs.modified == 'true'
|
2022-10-26 09:15:13 +03:00
|
|
|
uses: peter-evans/create-pull-request@v4
|
2021-07-02 10:07:05 +03:00
|
|
|
with:
|
|
|
|
title: Auto-format code with black
|
|
|
|
labels: meta
|
2021-07-02 10:40:49 +03:00
|
|
|
commit-message: Auto-format code with black
|
|
|
|
committer: GitHub <noreply@github.com>
|
2021-07-02 10:45:11 +03:00
|
|
|
author: explosion-bot <explosion-bot@users.noreply.github.com>
|
2021-07-02 10:07:05 +03:00
|
|
|
body: _This PR is auto-generated._
|
2021-07-02 10:30:59 +03:00
|
|
|
branch: autoblack
|
|
|
|
delete-branch: true
|
2021-07-02 10:07:05 +03:00
|
|
|
draft: false
|
|
|
|
- name: Check outputs
|
2021-07-02 10:37:35 +03:00
|
|
|
if: steps.git-check.outputs.modified == 'true'
|
2021-07-02 10:07:05 +03:00
|
|
|
run: |
|
|
|
|
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
|
|
|
|
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
|