peter-evans / autopep8

A GitHub action for autopep8, a tool that automatically formats Python code to conform to the PEP 8 style guide.
MIT License
84 stars 15 forks source link

[QUESTION] What am I doing wrong here? #59

Closed Morpheus636 closed 3 years ago

Morpheus636 commented 3 years ago

My Workflow:

name: autopep8
on: pull_request
jobs:
  autopep8:
    # Check if the PR is not raised by this workflow and is not from a fork
    if: startsWith(github.head_ref, 'autopep8-patches') == false && github.event.pull_request.head.repo.full_name == github.repository
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: autopep8
        id: autopep8
        uses: peter-evans/autopep8@v1
        with:
          args: --exit-code --recursive --in-place --aggressive --aggressive .
      - name: Set autopep8 branch name
        id: vars
        run: echo ::set-output name=branch-name::"autopep8-patches/$GITHUB_HEAD_REF"
      - name: Create Pull Request
        if: steps.autopep8.outputs.exit-code == 2
        uses: peter-evans/create-pull-request@v3
        with:
          commit-message: autopep8 action fixes
          title: Fixes by autopep8 action
          body: This is an auto-generated PR with fixes by autopep8.
          labels: autopep8
          branch: ${{ steps.vars.outputs.branch-name }}
      - name: Fail if autopep8 made changes
        if: steps.autopep8.outputs.exit-code == 2
        run: exit 1

Error: When the repository is checked out on a commit instead of a branch, the 'base' input must be supplied.

peter-evans commented 3 years ago

Hi @Morpheus636

It should be fixable by setting the base like this:

      - name: Create Pull Request
        if: steps.autopep8.outputs.exit-code == 2
        uses: peter-evans/create-pull-request@v3
        with:
          commit-message: autopep8 action fixes
          title: Fixes by autopep8 action
          body: This is an auto-generated PR with fixes by autopep8.
          labels: autopep8, automated pr
          reviewers: peter-evans
          branch: ${{ steps.vars.outputs.branch-name }}
+         base: ${{ github.head_ref }}
Morpheus636 commented 3 years ago

Thanks for your help!

jsoconno commented 2 years ago

I had the same issue. @peter-evans, do you know why this happens? I could not seem to reproduce the issue on my end.