Merge pull request #37 from COMP1511UNSW/dylanb/fix-generate_expected… #166
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-blacken | |
on: [push, pull_request] | |
jobs: | |
# job skipper in the case of concurrent push + pull_request trigger | |
pre_job: | |
runs-on: ubuntu-latest | |
outputs: | |
should_skip: ${{steps.skip_check.outputs.should_skip}} | |
steps: | |
- id: skip_check | |
uses: fkirc/skip-duplicate-actions@master | |
with: | |
concurrent_skipping: 'same_content' | |
do_not_skip: '["push"]' | |
# actual autoblacken | |
main_job: | |
name: runner / black | |
needs: pre_job | |
if: ${{needs.pre_job.outputs.should_skip != 'true'}} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
if: github.event_name == 'pull_request' | |
with: | |
fetch-depth: 0 | |
ref: ${{github.event.pull_request.head.ref}} | |
- uses: actions/checkout@v2 | |
if: github.event_name == 'push' | |
with: | |
fetch-depth: 0 | |
- name: Check files using the black formatter | |
uses: rickstaa/action-black@v1 | |
id: action_black | |
with: | |
black_args: "." | |
- name: Create commit on changes | |
if: steps.action_black.outputs.is_formatted == 'true' | |
run: | | |
git config --global user.name '${{github.actor}}' | |
git config --global user.email '${{github.actor}}@users.noreply.github.com' | |
git commit -am ":art: Format Python code with psf/black" -m "There appear to be some python formatting errors in ${{github.sha}}." | |
git push |