Compare commits
38 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
6c66175e66 | ||
|
050a3ed674 | ||
|
46e1a56aab | ||
|
e08c44a432 | ||
|
5220d8c625 | ||
|
802088666f | ||
|
d847f8f736 | ||
|
90bb33d882 | ||
|
9f49416da5 | ||
|
df93bbee53 | ||
|
f6bcbe6bd4 | ||
|
3a11ab50c5 | ||
|
8c81b32820 | ||
|
e2840e5a3e | ||
|
b4d3808a8b | ||
|
a5165775f4 | ||
|
416bd13f30 | ||
|
825a143e5b | ||
|
d43a690c6e | ||
|
2788447382 | ||
|
87e1ecde96 | ||
|
c03345ca95 | ||
|
190bf66f15 | ||
|
62953cd0e5 | ||
|
5565f737f4 | ||
|
c1f0b2fa3c | ||
|
e97ea1677f | ||
|
f3c6980bb2 | ||
|
025ffaabff | ||
|
f988078972 | ||
|
1aeea0844e | ||
|
639397b858 | ||
|
6864af49ad | ||
|
519c7c6b70 | ||
|
c682db2712 | ||
|
6f13ec1511 | ||
|
c0b74d876a | ||
|
ace48d7935 |
23
.github/dependabot.yml
vendored
Normal file
23
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: gomod
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
open-pull-requests-limit: 10
|
||||
groups:
|
||||
all:
|
||||
update-types:
|
||||
- "patch"
|
||||
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
open-pull-requests-limit: 10
|
||||
groups:
|
||||
all:
|
||||
update-types:
|
||||
- "minor"
|
||||
- "patch"
|
55
.github/workflows/ci.yaml
vendored
Normal file
55
.github/workflows/ci.yaml
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
name: ci
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test-ko-action:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
|
||||
with:
|
||||
go-version: '1.22'
|
||||
check-latest: 'true'
|
||||
|
||||
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
|
||||
|
||||
# Minimal publish
|
||||
- uses: ./
|
||||
|
||||
- run: ko publish --bare ./
|
||||
if: ${{ github.event_name == 'pull_request' }}
|
||||
env:
|
||||
KO_DOCKER_REPO: ko.local
|
||||
|
||||
- name: Install old release
|
||||
uses: ./
|
||||
with:
|
||||
version: v0.8.0
|
||||
|
||||
- name: Check installed version
|
||||
run: ko version | grep 0.8.0
|
||||
|
||||
- name: Install from tip
|
||||
uses: ./
|
||||
with:
|
||||
version: tip
|
||||
|
||||
- name: Check installed version (tip)
|
||||
run: |
|
||||
sudo rm /usr/local/bin/ko # Uninstall previous versions.
|
||||
ko version
|
||||
|
||||
# If KO_DOCKER_REPO is set during setup, it's set for future steps.
|
||||
- name: Pre-set KO_DOCKER_REPO
|
||||
uses: ./
|
||||
env:
|
||||
KO_DOCKER_REPO: already-set
|
||||
|
||||
- name: Check pre-set KO_DOCKER_REPO
|
||||
run: |
|
||||
if [[ "${KO_DOCKER_REPO}" != "already-set" ]]; then
|
||||
echo "${KO_DOCKER_REPO} != already-set"
|
||||
exit 1
|
||||
fi
|
29
.github/workflows/use-action.yaml
vendored
29
.github/workflows/use-action.yaml
vendored
@ -2,37 +2,47 @@ name: Use Action
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ['main']
|
||||
branches:
|
||||
- 'main'
|
||||
|
||||
jobs:
|
||||
use-action:
|
||||
name: Use Action
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
platform: [ubuntu-latest, macos-latest]
|
||||
platform:
|
||||
- ubuntu-latest
|
||||
- macos-latest
|
||||
|
||||
runs-on: ${{ matrix.platform }}
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-go@v2
|
||||
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
|
||||
with:
|
||||
go-version: 1.16
|
||||
- uses: actions/checkout@v2
|
||||
go-version: '1.22'
|
||||
check-latest: 'true'
|
||||
|
||||
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
|
||||
|
||||
# Minimal publish
|
||||
- uses: imjasonh/setup-ko@main
|
||||
- uses: ko-build/setup-ko@main
|
||||
|
||||
- run: ko publish --bare ./
|
||||
|
||||
- name: Install old release
|
||||
uses: imjasonh/setup-ko@main
|
||||
uses: ko-build/setup-ko@main
|
||||
with:
|
||||
version: v0.8.0
|
||||
|
||||
- name: Check installed version
|
||||
run: ko version | grep 0.8.0
|
||||
|
||||
- name: Install from tip
|
||||
uses: imjasonh/setup-ko@main
|
||||
uses: ko-build/setup-ko@main
|
||||
with:
|
||||
version: tip
|
||||
|
||||
- name: Check installed version (tip)
|
||||
run: |
|
||||
sudo rm /usr/local/bin/ko # Uninstall previous versions.
|
||||
@ -40,9 +50,10 @@ jobs:
|
||||
|
||||
# If KO_DOCKER_REPO is set during setup, it's set for future steps.
|
||||
- name: Pre-set KO_DOCKER_REPO
|
||||
uses: imjasonh/setup-ko@main
|
||||
uses: ko-build/setup-ko@main
|
||||
env:
|
||||
KO_DOCKER_REPO: already-set
|
||||
|
||||
- name: Check pre-set KO_DOCKER_REPO
|
||||
run: |
|
||||
if [[ "${KO_DOCKER_REPO}" != "already-set" ]]; then
|
||||
|
55
README.md
55
README.md
@ -1,6 +1,10 @@
|
||||
# GitHub Action to install and setup [`ko`](https://github.com/google/ko)
|
||||
# GitHub Action to install and setup [`ko`](https://github.com/ko-build/ko)
|
||||
|
||||
[![Build](https://github.com/imjasonh/setup-ko/actions/workflows/use-action.yaml/badge.svg)](https://github.com/imjasonh/setup-ko/actions/workflows/use-action.yaml)
|
||||
[![Build](https://github.com/ko-build/setup-ko/actions/workflows/use-action.yaml/badge.svg)](https://github.com/ko-build/setup-ko/actions/workflows/use-action.yaml)
|
||||
|
||||
> :warning: Note: `ko` recently [moved to its own GitHub org](https://github.com/ko-build/ko/issues/791), which broke `setup-ko@v0.5` if the `ko` version wasn't specified.
|
||||
>
|
||||
> To fix this, either upgrade to [`setup-ko@v0.6`](https://github.com/ko-build/setup-ko/releases/tag/v0.6) or specify `version`
|
||||
|
||||
## Example usage
|
||||
|
||||
@ -16,63 +20,63 @@ jobs:
|
||||
name: Publish
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/setup-go@v2
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: 1.15
|
||||
- uses: actions/checkout@v2
|
||||
go-version: '1.20.x'
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: imjasonh/setup-ko@v0.4
|
||||
- run: ko publish ./
|
||||
- uses: ko-build/setup-ko@v0.6
|
||||
- run: ko build
|
||||
```
|
||||
|
||||
_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]` 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://ko.build/configuration/) to learn more about configuring `ko`.
|
||||
|
||||
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).
|
||||
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 us know](https://github.com/ko-build/setup-ko/issues/new)!
|
||||
|
||||
### Select `ko` version to install
|
||||
|
||||
By default, `imjasonh/setup-ko` installs the [latest released version of `ko`](https://github.com/google/ko/releases).
|
||||
By default, `ko-build/setup-ko` installs the [latest released version of `ko`](https://github.com/ko-build/ko/releases).
|
||||
|
||||
You can select a version with the `version` parameter:
|
||||
|
||||
```yaml
|
||||
- uses: imjasonh/setup-ko@v0.4
|
||||
- uses: ko-build/setup-ko@v0.6
|
||||
with:
|
||||
version: v0.8.0
|
||||
version: v0.14.1
|
||||
```
|
||||
|
||||
To build and install `ko` from source using `go install`, specify `version: tip`.
|
||||
|
||||
### 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 as well.
|
||||
By default, `ko-build/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.
|
||||
|
||||
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:
|
||||
|
||||
```
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
...
|
||||
- uses: imjasonh/setup-ko@v0.4
|
||||
- uses: ko-build/setup-ko@v0.6
|
||||
env:
|
||||
KO_DOCKER_REPO: my.registry/my-repo
|
||||
- env:
|
||||
auth_token: ${{ secrets.auth_token }}
|
||||
run: |
|
||||
echo "${auth_token}" | ko login https://my.registry --username my-username --password-stdin
|
||||
ko publish ./
|
||||
ko build
|
||||
```
|
||||
|
||||
### Release Integration
|
||||
|
||||
In addition to publishing images, `ko` can produce YAML files containing references to built images, using [`ko resolve`](https://github.com/google/ko#kubernetes-integration)
|
||||
In addition to publishing images, `ko` can produce YAML files containing references to built images, using [`ko resolve`](https://ko.build/features/k8s)
|
||||
|
||||
With this action, you can use `ko resolve` to produce output YAML that you then attach to a GitHub Release using the [GitHub CLI](https://cli.github.com).
|
||||
For example:
|
||||
@ -82,18 +86,19 @@ name: Publish Release YAML
|
||||
|
||||
on:
|
||||
release:
|
||||
types: ['created']
|
||||
types:
|
||||
- 'created'
|
||||
|
||||
jobs:
|
||||
publish-release-yaml:
|
||||
name: Publish Release YAML
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/setup-go@v2
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: 1.15
|
||||
- uses: actions/checkout@v2
|
||||
- uses: imjasonh/setup-ko@v0.4
|
||||
go-version: '1.20'
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ko-build/setup-ko@v0.6
|
||||
|
||||
- name: Generate and upload release.yaml
|
||||
env:
|
||||
@ -106,6 +111,6 @@ jobs:
|
||||
|
||||
### A note on versioning
|
||||
|
||||
The `@v0.4` in the `uses` statement refers to the version _of the action definition in this repo._
|
||||
The `@v0.X` in the `uses` statement refers to the version _of the action definition in this repo._
|
||||
|
||||
Regardless of what version of the action definition you use, `imjasonh/setup-ko` will install the latest released version of `ko` unless otherwise specified with `version:`.
|
||||
Regardless of what version of the action definition you use, `ko-build/setup-ko` will install the latest released version of `ko` unless otherwise specified with `version:`.
|
||||
|
@ -5,7 +5,7 @@ branding:
|
||||
color: green
|
||||
inputs:
|
||||
version:
|
||||
description: 'Version of ko to install (tip, latest-release, v0.8.2, etc.)'
|
||||
description: 'Version of ko to install (tip, latest-release, v0.14.1, etc.)'
|
||||
required: true
|
||||
default: 'latest-release'
|
||||
runs:
|
||||
@ -50,6 +50,8 @@ runs:
|
||||
echo "${{ github.token }}" | ko login ghcr.io --username "dummy" --password-stdin
|
||||
|
||||
# Set KO_DOCKER_REPO for future steps.
|
||||
echo "KO_DOCKER_REPO=ghcr.io/${{ github.repository }}"
|
||||
echo "KO_DOCKER_REPO=ghcr.io/${{ github.repository }}" >> $GITHUB_ENV
|
||||
# We need to get the repository name in lowercase, otherwise it could fail
|
||||
repo=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
|
||||
echo "KO_DOCKER_REPO=ghcr.io/${repo}"
|
||||
echo "KO_DOCKER_REPO=ghcr.io/${repo}" >> $GITHUB_ENV
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user