Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Branch tip is behind remote #50

Open
kevinkace opened this issue Mar 19, 2020 · 6 comments
Open

Branch tip is behind remote #50

kevinkace opened this issue Mar 19, 2020 · 6 comments

Comments

@kevinkace
Copy link

I have an action to build some frontend files (webpack/gulp/less), and commit them back to the repo.

The push is failing:

Run ad-m/github-push-action@master
  with:
    github_token: ***
    branch: origin HEAD
    directory: .
  env:
    CI: true
Started: bash /home/runner/work/_actions/ad-m/github-push-action/master/start.sh
Push to branch origin HEAD
To https://github.com/animeplanet/ap-main.git
   1e4fca86d..0ad8fbe14  HEAD -> dm-action
 ! [rejected]            HEAD -> origin (non-fast-forward)
error: failed to push some refs to '***github.com/animeplanet/ap-main.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Error: Invalid status code: 1
    at ChildProcess.<anonymous> (/home/runner/work/_actions/ad-m/github-push-action/master/start.js:9:19)
    at ChildProcess.emit (events.js:210:5)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5) {
  code: 1
}
Error: Invalid status code: 1
    at ChildProcess.<anonymous> (/home/runner/work/_actions/ad-m/github-push-action/master/start.js:9:19)
    at ChildProcess.emit (events.js:210:5)

There is a git status command just prior to trying the push which shows the repo is up-to-date:

Run git status
  git status
  shell: /bin/bash -e {0}
On branch dm-action
Your branch is ahead of 'origin/dm-action' by 1 commit.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

My Build yaml:

name: BuildCssJs.js CI

on:
  push:
    branches:
      - 'dm-action'
      - 'staging'
      - 'dark-mode-fixes'
      - 'manga-chapters'
      - 'carousel-fix'
      - 'characters-edit-actions'
      - 'responsive-carousels'
    paths:
      - '.github/workflows/*'
      - 'gulpfile.js'
      - 'webpack.*'
      - 'src/assets/**/*'
      - 'public_html/inc/**/*.js'
      - 'public_html/inc/**/*.less'
      - '!public_html/inc/dist/**/*'
      - '!public_html/inc/*'

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [12.x]

    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - run: npm ci
    - run: npm run ci --if-present
    - run: git status
    - name: Commit files
      run: |
        git config --local user.email "[email protected]"
        git config --local user.name "GitHub Action"
        git add .
        git commit -m "Built CSS/JS - $(git rev-parse --short HEAD)"
    - run: git pull
    - run: git status
    - name: Push changes
      uses: ad-m/github-push-action@master
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        branch: 'origin HEAD'
      env:
        CI: true
@DarioRomano
Copy link

I'm having the same issue, and would be interested in a fix as well!

@vorcigernix
Copy link

Same issue here

@ad-m
Copy link
Owner

ad-m commented Jun 6, 2020

Your branch is ahead of 'origin/dm-action' by 1 commit.

I believe It seems to me that the information presented is not current. You would have to do "git fetch" before "git status" to get current information.

@vorcigernix
Copy link

Git pull solved it to me.

@William-Lake
Copy link

I had the same issue today and in my case it was because I was missing the branch portion (E.g. branch: ${{ github.ref }}).

After adding it to my workflow file the issue was resolved:

    - name: Push changes
      uses: ad-m/github-push-action@master
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        branch: ${{ github.ref }}

I'm curious about whether changing branch: 'origin HEAD' to branch: ${{ github.ref }} will do the trick in your case. I imagine it should, since it looks like you're trying to push to the same branch that triggered the action and github.ref will resolve to the current branch reference.

@mfouesneau
Copy link

Same issue. Is this solved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants