Skip to content

Commit

Permalink
Added fallback github deploy key
Browse files Browse the repository at this point in the history
  • Loading branch information
paualarco committed May 31, 2020
1 parent 7a74f60 commit 5a25b0d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/docusaurus.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ https://travis-ci.org/scalameta/mdoc/settings.

Add the following values:

- `GITHUB_DEPLOY_KEY`: the base64 encoded secret key. Note, the secret key is
- `GITHUB_DEPLOY_KEY` or `DEPLOY_KEY`: the base64 encoded secret key. Note, the secret key is
the file without the `.pub` extension
```sh
# macOS
Expand Down
13 changes: 8 additions & 5 deletions mdoc-sbt/src/main/scala/mdoc/DocusaurusPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,26 @@ object DocusaurusPlugin extends AutoPlugin {
|set -eu
|
|set-up-ssh() {
| KEY=$1
| echo "Setting up ssh..."
| mkdir -p $HOME/.ssh
| ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
| git config --global user.name "Docusaurus bot"
| git config --global user.email "${MDOC_EMAIL:-mdoc@docusaurus}"
| git config --global push.default simple
| DEPLOY_KEY_FILE=$HOME/.ssh/id_rsa
| echo "$GITHUB_DEPLOY_KEY" | base64 --decode > ${DEPLOY_KEY_FILE}
| echo "$KEY" | base64 --decode > ${DEPLOY_KEY_FILE}
| chmod 600 ${DEPLOY_KEY_FILE}
| eval "$(ssh-agent -s)"
| ssh-add ${DEPLOY_KEY_FILE}
|}
|DEPLOY_KEY=${GITHUB_DEPLOY_KEY:-}
|
|if [[ -n "$DEPLOY_KEY" ]]; then
| set-up-ssh
|fi
| if [[ -n "${GITHUB_DEPLOY_KEY:-}" ]]; then
| set-up-ssh ${GITHUB_DEPLOY_KEY}
| elif [[ -n "${DEPLOY_KEY:-}" ]]; then
| echo "Using fallback env var DEPLOY_KEY."
| set-up-ssh ${DEPLOY_KEY}
| fi
|
|yarn install
|USE_SSH=true yarn publish-gh-pages
Expand Down

0 comments on commit 5a25b0d

Please sign in to comment.