Update README.md

This commit is contained in:
Jason Hall 2021-10-28 11:14:58 -04:00 committed by GitHub
parent 789c5efa40
commit d7278ff6a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,17 +27,15 @@ jobs:
_That's it!_ This workflow will build and publish your code to [GitHub Container Regsitry](https://ghcr.io). _That's it!_ This workflow will build and publish your code to [GitHub Container Regsitry](https://ghcr.io).
By default, the action sets `KO_DOCKER_REPO=ghcr.io/[owner]/[repo]`. By default, the action sets `KO_DOCKER_REPO=ghcr.io/[owner]/[repo]` for all subsequent steps, and uses the `${{ github.token }}` to authorize pushes to GHCR.
See [documentation for `ko`](https://github.com/google/ko#configuration) to learn more about configuring `ko`. See [documentation for `ko`](https://github.com/google/ko#configuration) to learn more about configuring `ko`.
By default the action sets `KO_DOCKER_REPO` for all subsequent steps. The action works on Linux and macOS [runners](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners). If you'd like support for Windows runners, [let me know](https://github.com/imjasonh/setup-ko/issues/new).
Instead, if the `env` is already set when the action runs, it will skip logging in to ghcr.io and propagate `KO_DOCKER_REPO` for subsequent steps.
The action works on Linux and macOS [runners](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners), and _should_ work for Windows runners when `ko` releases include Windows binaries (next `ko` release🤞! see [google/ko#339](https://github.com/google/ko/pull/339))
### Select `ko` version to install ### Select `ko` version to install
By default, `imjasonh/setup-ko` installs the latest released version of `ko`. By default, `imjasonh/setup-ko` installs the [latest released version of `ko`](https://github.com/google/ko/releases).
You can select a version with the `version` parameter: You can select a version with the `version` parameter:
@ -51,18 +49,24 @@ To build and install `ko` from source using `go get`, specify `version: tip`.
### Pushing to other registries ### Pushing to other registries
By default, `imjasonh/setup-ko` configures `ko` to push images to [GitHub Container Registry](https://ghcr.io), but you can configure it to push to other registries. By default, `imjasonh/setup-ko` configures `ko` to push images to [GitHub Container Registry](https://ghcr.io), but you can configure it to push to other registries as well.
To do this, you need to provide credentials to authorize the push. If `KO_DOCKER_REPO` is already set when `setup-ko` runs, it will skip logging in to ghcr.io and will propagate `KO_DOCKER_REPO` for subsequent steps.
To do this, you should provide credentials to authorize the push.
You can use [encrypted secrets](https://docs.github.com/en/actions/reference/encrypted-secrets) to store the authorization token, and pass it to `ko login` before pushing: You can use [encrypted secrets](https://docs.github.com/en/actions/reference/encrypted-secrets) to store the authorization token, and pass it to `ko login` before pushing:
``` ```
steps:
...
- uses: imjasonh/setup-ko@v0.4 - uses: imjasonh/setup-ko@v0.4
env:
KO_DOCKER_REPO: my.registry/my-repo
- env: - env:
auth_token: ${{ secrets.auth_token }} auth_token: ${{ secrets.auth_token }}
run: | run: |
echo "${auth_token}" | ko login https://my.registry --username my-username --password-stdin echo "${auth_token}" | ko login https://my.registry --username my-username --password-stdin
export KO_DOCKER_REPO=my.registry/my-repo
ko publish ./ ko publish ./
``` ```