diff --git a/.github/workflows/autoblack.yml b/.github/workflows/autoblack.yml index ba9cc36..e2f9cfd 100644 --- a/.github/workflows/autoblack.yml +++ b/.github/workflows/autoblack.yml @@ -11,22 +11,31 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - name: Set up Python 3.7 - uses: actions/setup-python@v1 + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v4 with: - python-version: 3.9 + python-version: 3.10 - name: Install Black run: pip install black - name: Run black --check . run: black --check . - - name: If needed, commit black changes to the pull request - if: failure() + - name: Commit files + id: commit run: | - black . --line-length 101 - git config --global user.name 'autoblack' - git config --global user.email 'jasoncameron.all@gmail.com' - git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY - git checkout $GITHUB_HEAD_REF - git commit -am "fixup: Format Python code with Black" - git push + git config --local user.email "action@github.com" + git config --local user.name "github-actions" + git add --all + if [-z "$(git status --porcelain)"]; then + echo "::set-output name=push::false" + else + git commit -m "Added translation" -a + echo "::set-output name=push::true" + fi + shell: bash + - name: Push changes + if: steps.commit.outputs.push == 'true' + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: main