GitHub returns 401 (Unauthorized) when I'm deploying to GitHub releases

Hi,
I’m using Travis CI on a public GitHub repo and deploying files to GitHub releases, when I’m setting up the deployment, I simplify use this command:

$ travis setup --org --force

and follow up the wizard.
It creates a personal token on GitHub and deployment codes in .travis.yml:

deploy:
  name: ${VERSION}
  body: Relaese body
  prerelease: true
  provider: releases
  api_key:
    secure: rvV6A3CK...kGi0=
  file: app/build/outputs/apk/release/app.apk
  on:
    repo: Trumeet/MiPushTester

You can view it on GitHub
Unfortunately, the build always says Unauthorized:

Installing deploy dependencies
invalid options: -SHN
(invalid options are ignored)
Successfully installed .....
Preparing deploy
No stash entries found.
/home/travis/.rvm/gems/ruby-2.4.1/gems/octokit-4.6.2/lib/octokit/response/raise_error.rb:16:in `on_complete': GET https://api.github.com/user: 401 - Bad credentials // See: https://developer.github.com/v3 (Octokit::Unauthorized)

I have no idea about this, could everyone help me? Thanks.

You need to set skip_cleanup: true; otherwise your build artifacts will be deleted before deployment. See https://docs.travis-ci.com/user/deployment/releases

Thanks for your quick reply, but I’ve tried your solution and it breaks down with the same error.
The updated .travis.yml:

deploy:
  name: ${VERSION}
  body: ...body is ignored
  prerelease: true
  provider: releases
  skip_cleanup: true
  api_key:
    secure: rvV6A3...Gi0=
  file: app/build/outputs/apk/release/app.apk
  on:
    repo: Trumeet/MiPushTester

Thanks for the info.

I now see that you are running your builds on https://travis-ci.com. This necessitates that you pass --pro flag when you are interacting with travis CLI. Try running

travis encrypt -r Trumeet/MiPushTester --pro

to encrypt your API key, and replacing the secure key-value pair.

Sorry, I’m using .org, not .com, here is my build logs URL: https://travis-ci.org/Trumeet/MiPushTester

Are there anybody wants to give me a hand? :cry:

On .org, your build is failing, so no deployment occurs.

On .com, your build succeeds, but deployment fails.

Thanks a lot, I confused org and com, and added environment variables to the wrong way :grinning: