grunt-gh-pages icon indicating copy to clipboard operation
grunt-gh-pages copied to clipboard

Read authentication credentials from environment

Open kewisch opened this issue 9 years ago • 1 comments

I'd like to use this in an environment with travis. There are two common options authentication there, one being a github personal access token, the other to use a project specific deployment ssh key. Both are read via the environment, the ssh key is usually base64 encoded.

I'm not totally sure ssh key via env works, I've read reports that the travis environment variables are too short for a full ssh key, but from a simple test it seemed to work for me.

What do you think about adding support for this to grunt-gh-pages? I'd imagine something like this in the config:

// ssh key from environment:
"gh-pages": {
  repo: "[email protected]:tschaub/grunt-gh-pages.git"
  sshEnv: "GITHUB_KEY"
}
// token from env
"gh-pages": {
  repo: "https://github.com/tschaub/grunt-gh-pages.git"
  tokenEnv: "GITHUB_TOKEN"
}

In the first case, it would read that key, base64-decode it, write it to a temporary file, call ssh-add on it. In the second case, it would parse the repo url and add the token as a username, e.g. https://[email protected]/tschaub/grunt-gh-pages.git. If you prefer, we could use a single config key envAuth and then detect if its a https repo url or ssh url.

If you are up for this, I could probably find some time to send a pull request. On the other hand, this can of course be done with a custom task that runs beforehand and sets the right config values.

kewisch avatar May 25 '15 16:05 kewisch

any thoughts on that?

I got the same issue when I try to deploy within a Github action

Draym avatar Jul 05 '21 09:07 Draym