Automated formatting changes #27
Workflow file for this run
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: Python Formatting | |
on: [push, pull_request] | |
jobs: | |
formatting: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.x" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install black isort | |
pip install "black[jupyter]" | |
- name: Run Black | |
run: | | |
black --check . || true | |
find . -name '*.py' -exec black {} \; || true | |
- name: Set Git Identity | |
run: | | |
git config --global user.email "124101026+Elias2660@users.noreply.github.com" | |
git config --global user.name "Elias Xu" | |
- name: Check for changes | |
id: changes | |
run: | | |
git diff --quiet && echo "::set-output name=changed::false" || echo "::set-output name=changed::true" | |
- name: Create Pull Request | |
if: steps.changes.outputs.changed == 'true' && github.event_name != 'pull_request' | |
uses: peter-evans/create-pull-request@v3 | |
with: | |
token: ${{ secrets.WORKFLOW_GITHUB_TOKEN }} | |
commit-message: "Automated formatting changes" | |
title: "Automated formatting changes" | |
body: "This is an auto-generated PR with formatting changes." | |
branch: "formatting-changes" | |
base: "main" # replace 'main' with your default branch if it's different | |
- name: Commit changes | |
if: steps.changes.outputs.changed == 'true' && github.event_name == 'pull_request' | |
run: | | |
git add . | |
git commit -m "Automated formatting changes" | |
git push |