travis-ci 401 - Bad credentials // See: https://developer.github.com/v3 (Octokit::Unauthorized) - travis-ci

I created a GitHub personal access token with repo, read:repo_hook, and user:email scopes, then encrypted the token with travis encrypt, then pasted that string into my .travis.yml file in the deploy block, but when I tag a release, my job fails with:
Installing deploy dependencies
/home/travis/.rvm/gems/ruby-2.4.5/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 know the encrypted string works, because it does successfully upload the files to my release tag and the github logs show that the key was accessed this week, but I can't figure out why this error is happening.
Here is a link to the build: https://travis-ci.com/github/benkonz/gameboy_emulator/jobs/331211965
Here is a link to the repo: https://github.com/benkonz/gameboy_emulator

i have the same issues,
the reason is my $GITHUB_TOKENis set in travis settings.
but my .travis.yml is set in secure mode.
deploy:
...
api_key:
secure: $GITHUB_TOKEN
...
so , i change my .travis.yml
deploy:
...
api_key: $GITHUB_TOKEN
....
sloved my problem.

Related

Missing Master Key Error Github Action with test.key stored as a secret

I am going crazy with Rails Credentials!
I have a Missing Master Key Error when launching my Github Action test.
I have
generated credentials/test.key and credentials/test.yml.enc with rails credential:edit -e test command,
stored the content of test.key in a GITHUB Actions Secret
referenced it in my Github Action
env:
RAILS_ENV: test
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
Still say "Missing Key"...
I also have done the same in production (as before the master.key was stored on Github!!)
You could run the following to add the key under config before you start running the tests.
echo "$RAILS_MASTER_KEY" > config/master.key

Rails & Github Actions - Credentials

I have a Rails 6 app using the credentials storage built into Rails and I am running testing and CI on this app with Github Actions.
I have initializer code that uses credentials that passes test on my local machine because it uses credentials from config/credentials/test.yml.enc, however Actions can't access this file. I have seen suggestions online to set RAILS_MASTER_KEY as an environment variable with the key value from the credential key file, but I have set up RAILS_TEST_KEY (and RAILS_MASTER_KEY) to be the value of config/credentials/test.key with no luck. Does Rails know to look for this environment variable if the key file isn't present, or do I need to do something to point it to this variable?
Apologies, if i didn’t understand your question correctly. You can reference CI ENV variables using repository secrets. For example if you have ENV variable called RAILS_TEST_KEY in your CI yml file.
env:
RAILS_TEST_KEY: ${{ secrets.RAILS_TEST_KEY }}
secrets.RAILS_TEST_KEY value can be set in repository secrets.
https://docs.github.com/en/actions/reference/encrypted-secrets

Failing Travis CI tests when using secret keys in rails

I am using environment variables in secrets.yml for production environment in my rails app. I am sending http post request with api key and password. I can pass my local tests in test environment by using the password. But my password can't be exposed, so how do I pass travis ci tests on github?
You can encrypt your secrets.yml and push encrypted file to the repository.
travis encrypt-file secrets.yml
which will give you secrets.yml.enc add it to repository. Remember not to push secrets.yml.
You need to decrypt that file in before_script
before_script: openssl aes-256-cbc -K $encrypted_0a6446eb3ae3_key -iv $encrypted_0a6446eb3ae3_key -in secrets.yml.enc -out secrets.yml -d
You can directly add above command to travis.yml using --add option:
travis encrypt-file secrets.yml --add
Refer this documentation for more details - Encrypting Files in Travis

Auto deploy after commiting

I'm developing on Ruby on Rails and write some articles on Hexo.
My project source code repo is on Gitlab server.
So my deploy flow is
Commit the production code to Gitlab from my working space.
Login in the Web server, then pull the production code from Gitlab
Restart the Webserver, or regenerate articles for Hexo.
Is there any way to let me, renew the webserver with one step ?
hexo is on node so not sure how ruby on rails fits in. I would recommend you take a look at their documentation which has few plugins for deployments link
pasting an excerpt that's valid at this moment
Edit _config.yml.
deploy:
type: git
message: [message]
repo:
gitlab: <repository url>,[branch]
gitcafe: <repository url>,[branch]
It's better to setup a GitLab hook which should call a hexo generate command.

Heroku can't find facebook.yml file; what is going on?

I am deploying an app that works locally to heroku. My heroku logs produce the following error:
/usr/ruby1.9.2/lib/ruby/1.9.1/syck.rb:145:in
`initialize': No such file or
directory -
/app/2c325e9f-adb9-420e-b7d8-a80f8aa4c4e6/home/config/facebook.yml
My facebook.yml file is in the /config directory and is formatted as such:
development:
app_id
secret_key
test:
app_id
secret_key
production:
app_id
secret_key
My guess is that you forgot to...
git add facebook.yml
git commit -m 'new file' .
prior to
git push heroku master
Althouh DigitalRoss answer works may not always be a best practice.
Adding yaml files to repository you put sensitive information into your git account
leaving security issues (eg. if code is shared in github or else).
Here's what heroku suggest.

Resources