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 6b2c657
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: ci
on:
push:
branches:
- main
release:
pull_request: #dev only, remove me!!!


jobs:
build-test:
name: build
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: Run a ko build
run: just build
env:
KO_DOCKER_REPO: ghcr.io/cofide/cofidectl-debug-container
- name: Tag the image with the release tag
if: github.event_name == 'release'
run: |
docker tag ghcr.io/cofide/cofidectl-debug-container:latest ghcr.io/cofide/cofidectl-debug-container:${GITHUB_REF#refs/tags/}
- name: Tag the image with the commit hash
if: github.event_name != 'release'
run: |
docker tag ghcr.io/cofide/cofidectl-debug-container:latest ghcr.io/cofide/cofidectl-debug-container:${GITHUB_SHA}
- name: Login to GitHub Container Registry
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u cofide --password-stdin
- name: Push the release tag
if: github.event_name == 'release'
run: |
docker push ghcr.io/cofide/cofidectl-debug-container:${GITHUB_REF#refs/tags/}
- name: Push the commit hash
if: github.event_name == 'release'
run: |
docker push ghcr.io/cofide/cofidectl-debug-container:${GITHUB_SHA}

0 comments on commit 6b2c657

Please sign in to comment.