Skip to content

Commit

Permalink
Add CI action to release to GHCR
Browse files Browse the repository at this point in the history
Signed-off-by: Maartje Eyskens <[email protected]>
  • Loading branch information
meyskens committed Nov 22, 2024
1 parent 2463bd5 commit 8c31021
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
46 changes: 46 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: docker-image
on:
push:
branches:
- main
- release-ghcr
release:


jobs:
build-test:
name: build
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install just
uses: taiki-e/install-action@just
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Create Kind Cluster
uses: helm/kind-action@v1
with:
cluster_name: kind
- name: Install ko
uses: ko-build/[email protected]
env:
KO_DOCKER_REPO: kind.local
- name: Install dependencies
run: |
go mod download
- name: Set KO_TAG to the current commit
run: echo "KO_TAG=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Set KO_TAG to version if it is a release
if: github.event_name == 'release'
run: echo "KO_TAG=$(echo $GITHUB_REF | cut -d / -f 3)" >> $GITHUB_ENV
- name: Run a ko build
run: just build
env:
KO_DOCKER_REPO: ghcr.io/cofide/cofidectl-debug-container/cmd
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set shell := ["bash", "-euo", "pipefail", "-c"]

export KO_DOCKER_REPO := env_var_or_default("KO_DOCKER_REPO", "kind.local")
export KIND_CLUSTER_NAME := env_var_or_default("KIND_CLUSTER_NAME", "kind")
export KO_TAG := env_var_or_default("KO_TAG", "latest")

lint *args:
golangci-lint run --show-stats {{args}}
Expand All @@ -20,4 +21,4 @@ check-deps:

# Build application
build: check-deps
ko build github.com/cofide/cofidectl-debug-container/cmd
ko build --bare --tags="$KO_TAG" github.com/cofide/cofidectl-debug-container/cmd

0 comments on commit 8c31021

Please sign in to comment.