Skip to content

Creates new branch even if it exits #142

@1itachi

Description

@1itachi

Version of the Action
v4.9.0

Describe the bug
Creates a new branch even if the remote with the same name exists.

Switched to a new branch 'automatic-sync'
INPUT_FILE_PATTERN: .editorconfig
To https://github.com/<repo>
 ! [rejected]        HEAD -> automatic-sync (non-fast-forward)
error: failed to push some refs to 'https://github.com/<repo>'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

To Reproduce
Steps to reproduce the behavior:

  1. Give a new branch name and commit some changes
  2. Run the same workflow a second time

Expected behavior
Needs to check if the remote branch exists, compare the difference, and commit only if a change is found.

Used Workflow

name: sync template
on: push

jobs:
  check-version-change:
    runs-on: [self-hosted, linux]
    steps:
    - uses: actions/checkout@v2

    - name: Copy file
      run: ***does something*******

    - name: commit and push
      uses: stefanzweifel/git-auto-commit-action@v4
      with: 
        commit: "Apply automatic changes"
        branch: "automatic-sync"
        file_pattern: ".editorconfig"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions