devmasx / merge-branch

A GitHub Action that merge PR branch to other branchs
161 stars 58 forks source link

Getting 404 #7

Closed alagos closed 4 years ago

alagos commented 4 years ago

Trying github actions for the 1st time here. My plans are to update any new pull request with last master changes:

on:
  pull_request:
    branches:
      - "release/**"
jobs:
  sync-branch:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - name: Merge master -> release
        uses: devmasx/merge-branch@v1.3.0
        with:
          type: now
          head_to_merge: master
          target_branch: ${{ github.ref }}
          github_token: ${{ github.token }}

but this it's throwing me:

/usr/local/bundle/gems/octokit-4.14.0/lib/octokit/response/raise_error.rb:16:in `on_complete': POST https://api.github.com/repos/visfleet/test-merge-action/merges: 404 - Base does not exist // See: https://docs.github.com/rest/reference/repos#merge-a-branch (Octokit::NotFound)
    from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/response.rb:9:in `block in call'
    from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/response.rb:61:in `on_complete'
    from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/response.rb:8:in `call'
    from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/middleware/follow_redirects.rb:73:in `perform_with_redirection'
    from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/middleware/follow_redirects.rb:61:in `call'
    from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/request/retry.rb:130:in `call'
    from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/rack_builder.rb:143:in `build_response'
    from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/connection.rb:387:in `run_request'
    from /usr/local/bundle/gems/faraday-0.17.0/lib/faraday/connection.rb:175:in `post'
    from /usr/local/bundle/gems/sawyer-0.8.2/lib/sawyer/agent.rb:94:in `call'
    from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/connection.rb:156:in `request'
    from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/connection.rb:28:in `post'
    from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/client/commits.rb:214:in `merge'
    from /action/lib/index.rb:21:in `<main>'

My guessing is the problem comes from the access token, so I've tried using github_token: ${{ secrets.GITHUB_TOKEN }}, also adding:

        env:
          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

but nothing seems to work. Any idea?

alagos commented 4 years ago

Found the issue, I changed

target_branch: ${{ github.ref }}

to

target_branch: ${{ github.head_ref }}

and it worked.

imcvakt commented 3 years ago

I'm facing the same issue. What's : ${{ github.head_ref }}

rsodre commented 2 years ago

Was having this issue because the target_branch did not exist yet.

xmollv commented 10 months ago

Was having this issue because the target_branch did not exist yet.

How did you end up solving it? We seem to have the same issue! 🙏

rsodre commented 10 months ago

I don't really remember what's this issue about. But I guess that target_branch must exist before you run the action?

xmollv commented 10 months ago

I don't really remember what's this issue about. But I guess that target_branch must exist before you run the action?

It turned out that our token didn't have enough permissions. When trying the same thing with a token that's an org admin, it worked.