Skip to content

Simple Travis secret #3

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

szepeviktor
Copy link

Simply store the SSH private key base64-encoded
base64_4950820e8b20_key

@szepeviktor
Copy link
Author

Using a modern ed25519 key makes it fun!

Copy link
Member

@aaemnnosttv aaemnnosttv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @szepeviktor

I like your idea, but as I recall, Travis has a limit on the length of a secret that can be stored in settings. I don't have the source for that off-hand, but it may have been that I didn't think to encode the key like you're saying to preserve the new lines. If that's all it takes then I like the idea of removing the encrypted file from the repo.

With that said, I'm hesitant to make changes to the repo here when it's otherwise working just fine 😄

A few comments for you on your suggested changes below.

@@ -12,6 +12,12 @@ cache:
- $HOME/.composer/cache
- repos/wordpress

before_install:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change this to before_install? The install step only runs Composer, which does not require SSH (only the script does). The key is actually really only needed for the deploy step but I seem to recall the git clone would fail without it using ssh for the remote.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

install does the installation of Composer packages which are actually part of this software.
before_install does the prerequisites for running CI.
I hope that is clear :)

.travis.yml Outdated
Comment on lines 17 to 19
- echo -n "${base64_4950820e8b20_key}" | base64 --decode >.travis/key
- chmod 600 .travis/key
- ssh-add .travis/key
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If extracting the key to a secret (which seems to be what you're suggesting here), then the encrypted key in the repo is no longer needed either since ssh-add can read from STDIN (see this answer).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@szepeviktor
Copy link
Author

Travis has a limit on the length of a secret that can be stored in settings.

Good point! An ed25519 key is very short. Please try generating one.

.travis.yml Outdated
@@ -12,6 +12,10 @@ cache:
- $HOME/.composer/cache
- repos/wordpress

before_install:
- eval "$(ssh-agent -s)"
- echo -n "${base64_4950820e8b20_key}" | ssh-add -
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would still need to be base64 decoded before adding, would it not?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

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

Successfully merging this pull request may close these issues.

2 participants