GitHub returns 404 when trying to deploy using github releases

I cannot seem to figure out the wizardry necessary to publish a release from Travis. I’ve followed the instructions at https://docs.travis-ci.com/user/deployment/releases/ and no combination seems to actually get a release to appear in Github. For example, see the following build https://travis-ci.org/patchup/patchup/builds/573252391

/home/travis/.rvm/gems/ruby-2.4.5/gems/octokit-4.6.2/lib/octokit/response/raise_error.rb:16:in `on_complete': POST https://api.github.com/repos/patchup/patchup/releases: 404 - Not Found // See: https://developer.github.com/v3/repos/releases/#create-a-release (Octokit::NotFound)
	from /home/travis/.rvm/gems/ruby-2.4.5/gems/faraday-0.15.4/lib/faraday/response.rb:9:in `block in call'
	from /home/travis/.rvm/gems/ruby-2.4.5/gems/faraday-0.15.4/lib/faraday/response.rb:61:in `on_complete'
	from /home/travis/.rvm/gems/ruby-2.4.5/gems/faraday-0.15.4/lib/faraday/response.rb:8:in `call'
	from /home/travis/.rvm/gems/ruby-2.4.5/gems/octokit-4.6.2/lib/octokit/middleware/follow_redirects.rb:73:in `perform_with_redirection'
	from /home/travis/.rvm/gems/ruby-2.4.5/gems/octokit-4.6.2/lib/octokit/middleware/follow_redirects.rb:61:in `call'
	from /home/travis/.rvm/gems/ruby-2.4.5/gems/faraday-0.15.4/lib/faraday/rack_builder.rb:143:in `build_response'
	from /home/travis/.rvm/gems/ruby-2.4.5/gems/faraday-0.15.4/lib/faraday/connection.rb:387:in `run_request'
	from /home/travis/.rvm/gems/ruby-2.4.5/gems/faraday-0.15.4/lib/faraday/connection.rb:175:in `post'
	from /home/travis/.rvm/gems/ruby-2.4.5/gems/sawyer-0.8.2/lib/sawyer/agent.rb:94:in `call'
	from /home/travis/.rvm/gems/ruby-2.4.5/gems/octokit-4.6.2/lib/octokit/connection.rb:154:in `request'
	from /home/travis/.rvm/gems/ruby-2.4.5/gems/octokit-4.6.2/lib/octokit/connection.rb:28:in `post'
	from /home/travis/.rvm/gems/ruby-2.4.5/gems/octokit-4.6.2/lib/octokit/client/releases.rb:32:in `create_release'
	from /home/travis/.rvm/gems/ruby-2.4.5/gems/dpl-releases-1.10.12/lib/dpl/provider/releases.rb:116:in `push_app'
	from /home/travis/.rvm/gems/ruby-2.4.5/gems/dpl-1.10.12/lib/dpl/provider.rb:199:in `block in deploy'
	from /home/travis/.rvm/gems/ruby-2.4.5/gems/dpl-1.10.12/lib/dpl/cli.rb:41:in `fold'
	from /home/travis/.rvm/gems/ruby-2.4.5/gems/dpl-1.10.12/lib/dpl/provider.rb:199:in `deploy'
	from /home/travis/.rvm/gems/ruby-2.4.5/gems/dpl-1.10.12/lib/dpl/cli.rb:32:in `run'
	from /home/travis/.rvm/gems/ruby-2.4.5/gems/dpl-1.10.12/lib/dpl/cli.rb:7:in `run'
	from /home/travis/.rvm/gems/ruby-2.4.5/gems/dpl-1.10.12/bin/dpl:5:in `<top (required)>'
	from /home/travis/.rvm/gems/ruby-2.4.5/bin/dpl:23:in `load'
	from /home/travis/.rvm/gems/ruby-2.4.5/bin/dpl:23:in `<main>'
failed to deploy

Two things.

  1. Your have both https://travis-ci.org and https://travis-ci.com enabled. I suggest disabling the former, as we will be moving everything to that host in the near future.
  2. On the latter, in https://travis-ci.com/patchup/patchup/builds/123611574#L321 you see that the token is unauthorized. I suggest double checking the token, and ensure that it has the repo or public_repo scope.

Hm, I’m not actually sure how I wound up with both enabled. In fact, I’m not entirely sure I know which “enabled” you’re referring to exactly… I think I have now disabled the .org version? I re-encrypted the token using travis encrypt --pro <github personal access token> just to be sure, but it looks like it’s still 404’ing for me: https://travis-ci.com/patchup/patchup/jobs/226079890

Also, is there a better way to test travis configs in the .com-land? There was a “run this build with a custom travis config” option in the .org version that was super handy for testing this stuff since it doesn’t involve committing to the repo to trigger it.

Also, I’m not sure if it might be contributing, but rather than bump my version tag each time I want to test this, I’m deleting the tag and recreating it. Is it possible it’s trying to do a delta with a prior tag somehow and that’s what is 404’ing?

“Trigger a build” should be available on the drop-down menu on https://travis-ci.com/ for you, if you are authenticated and has push access to the repo.

Since the response is 404 rather than 401, I have to believe that the API key is correctly decrypted and was able to confirm the correct scope.

The only way I was able to reproduce a 404 response for the create-a-release call is that the token does not have the push access to the repository itself:

[15] pry(main)> api=Octokit::Client.new(access_token: "abcdef0123456789", auto_paginate: true)
=> #<Octokit::Client:0x00007f8a71ae9ab8 ...>
[16] pry(main)> api.scopes
=> ["repo"]
[17] pry(main)> api.create_release("patchup/patchup","v1.0")
Octokit::NotFound: POST https://api.github.com/repos/patchup/patchup/releases: 404 - Not Found // See: https://developer.github.com/v3/repos/releases/#create-a-release
from /Users/asari/.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/octokit-4.14.0/lib/octokit/response/raise_error.rb:16:in `on_complete'
[18] pry(main)> api.create_release("BanzaiMan/travis_production_test","1234567890")
=> {:url=>
  "https://api.github.com/repos/BanzaiMan/travis_production_test/releases/19358723",
 :assets_url=>
  "https://api.github.com/repos/BanzaiMan/travis_production_test/releases/19358723/assets",
⋮

That was it! I was following the “create a ‘machine user’” suggestion, but hadn’t enabled write access to the repo for that new user. After fixing that permission, it looks like it’s working now. Thanks a ton helping track this down!

Hi! I have faced with the same problem. Could you please explain how to enable write access?