Bump to version 0.9.0 #147
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: auto-format | |
on: pull_request | |
jobs: | |
format: | |
# Check if the PR is not from a fork | |
if: github.event.pull_request.head.repo.full_name == github.repository | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
with: | |
ref: ${{ github.head_ref }} | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9 | |
- name: Run isort to sort dependencies | |
uses: isort/[email protected] | |
with: | |
sort-paths: "src" | |
configuration: "--profile black" | |
# Run isort before black so that black has the final say in formatting. | |
- name: run black to auto-format python code | |
uses: psf/[email protected] | |
with: | |
src: "src" | |
options: "--verbose --line-length 120" | |
- name: Check if any files were modified | |
id: git-check | |
run: echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi) | |
- name: Push changes if needed | |
if: steps.git-check.outputs.modified == 'true' | |
run: | | |
git config --global user.name 'Auto-format Bot' | |
git config --global user.email '[email protected]' | |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} | |
git commit -am "Automatically reformatting code with black and isort" | |
git push |