Skip to content
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

Support GIT_DEPLOY_KEY as alternative to GITHUB_DEPLOY_KEY #352

Merged
merged 2 commits into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions docs/docusaurus.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ several steps:
http://static.javadoc.io/

The static website gets generated in the `website/build` directory. You can copy
these files over to any static HTTP server to host your website. A simple `sbt docs/clean`
will delete the previous folder since the `DocusaurusPlugin` will also bind it to the
standard SBT `clean` task.
these files over to any static HTTP server to host your website. A simple
`sbt docs/clean` will delete the previous folder since the `DocusaurusPlugin`
will also bind it to the standard SBT `clean` task.

## Publish to GitHub pages locally

Expand Down Expand Up @@ -134,8 +134,8 @@ https://travis-ci.org/scalameta/mdoc/settings.

Add the following values:

- `GITHUB_DEPLOY_KEY`: the base64 encoded secret key. Note, the secret key is
the file without the `.pub` extension
- `GITHUB_DEPLOY_KEY` or `GIT_DEPLOY_KEY`: the base64 encoded secret key. Note,
the secret key is the file without the `.pub` extension
```sh
# macOS
cat myproject | base64 | pbcopy
Expand Down Expand Up @@ -184,7 +184,9 @@ docs 😎

## Include Scaladoc in site

You can configure a project to include Scaladocs in its site. Below is an example configuration that uses [sbt-unidoc](https://github.com/sbt/sbt-unidoc) to aggregate Scaladocs across multiple projects.
You can configure a project to include Scaladocs in its site. Below is an
example configuration that uses [sbt-unidoc](https://github.com/sbt/sbt-unidoc)
to aggregate Scaladocs across multiple projects.

```diff
// build.sbt
Expand All @@ -202,9 +204,13 @@ You can configure a project to include Scaladocs in its site. Below is an exampl
.dependsOn(myproject1, myproject2)
```

Make sure that you've added the [sbt-unidoc](https://github.com/sbt/sbt-unidoc#how-to-add-this-plugin) dependency to `project/plugins.sbt`.
Make sure that you've added the
[sbt-unidoc](https://github.com/sbt/sbt-unidoc#how-to-add-this-plugin)
dependency to `project/plugins.sbt`.

Now the `docs/docusaurusCreateSite` command will generate Scaladocs in the `website/static/api` directory, which you'll probably want to add to your `.gitignore`:
Now the `docs/docusaurusCreateSite` command will generate Scaladocs in the
`website/static/api` directory, which you'll probably want to add to your
`.gitignore`:

```diff
// .gitignore
Expand All @@ -217,7 +223,8 @@ Now the `docs/docusaurusCreateSite` command will generate Scaladocs in the `webs
+ website/static/api
```

You'll need to tweak your `siteConfig.js` file to make Docusaurus play nicely with Scaladoc's CSS. You may want to add a header link to your API docs too:
You'll need to tweak your `siteConfig.js` file to make Docusaurus play nicely
with Scaladoc's CSS. You may want to add a header link to your API docs too:

```diff
// website/siteConfig.js
Expand Down
9 changes: 5 additions & 4 deletions mdoc-sbt/src/main/scala/mdoc/DocusaurusPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ object DocusaurusPlugin extends AutoPlugin {
"""|#!/usr/bin/env bash
|
|set -eu
|
|DEPLOY_KEY=${GIT_DEPLOY_KEY:-$GITHUB_DEPLOY_KEY}
|set-up-ssh() {
| echo "Setting up ssh..."
| mkdir -p $HOME/.ssh
Expand All @@ -63,15 +63,16 @@ object DocusaurusPlugin extends AutoPlugin {
| 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 "$DEPLOY_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
|if [[ -n "${DEPLOY_KEY:-}" ]]; then
| set-up-ssh
|else
| echo "Can't setup SSH. To fix this problem, set the GIT_DEPLOY_KEY environment variable."
|fi
|
|yarn install
Expand Down