Skip to content

Protected branch update failed #739

Closed
@eikowagenknecht

Description

@eikowagenknecht

I'm in the process of setting up python-semantic-release for one of my repositories.

Since I need Python 3.11, I can not use the dockerized GitHub Action and use the following instead:

  release:
    name: Release
    if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'chore(release):')
    runs-on: ubuntu-latest
    concurrency: release
    permissions:
      id-token: write
      contents: write
    steps:
      - name: Check out repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Setup Python 3.11
        uses: actions/setup-python@v4
        with:
          python-version: "3.11"

      - name: Install python-semantic-release
        run: |
          pip install python-semantic-release

      - name: Semantic release
        env:
          GH_TOKEN: ${{ secrets.GH_SEMREL }}
        run: |
          semantic-release version

GH_SEMREL contains a "classic" PAT with the repo scope.

But I still only get the message

...
    raise GitCommandError(redacted_command, status, stderr_value, stdout_value)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(1)
  cmdline: git push ***github.com/***/***.git main
  stderr: 'remote: error: GH006: Protected branch update failed for refs/heads/main.        
remote: error: Changes must be made through a pull request.        
To https://github.com/***/***.git
 ! [remote rejected] main -> main (protected branch hook declined)
error: failed to push some refs to 'https://github.com/***/***.git''
Error: Process completed with exit code 1.

What am I doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions