Skip to content

Commit

Permalink
Publish container images
Browse files Browse the repository at this point in the history
Configure GitHub actions to build and publish
container images.

Signed-off-by: Andrea Panattoni <[email protected]>
  • Loading branch information
zeeke committed Mar 13, 2024
1 parent 3c83f06 commit 03e1a7a
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/build-test-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ jobs:
GOOS: ${{ matrix.goos }}
run: make build

build-image:
runs-on: ubuntu-22.04
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Build and push container image
uses: docker/build-push-action@v5
with:
context: .
push: false
file: ./Dockerfile


test:
runs-on: ubuntu-latest
needs: build
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/image-push-master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "Push images on merge to master"
on:
push:
branches:
- master
jobs:
build-and-push-image:
runs-on: ubuntu-22.04
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Login to Docker
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push container image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ github.sha }}
file: ./Dockerfile
36 changes: 36 additions & 0 deletions .github/workflows/image-push-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "Push images on release"
on:
push:
tags:
- v*
jobs:
build-and-push-image:
runs-on: ubuntu-22.04
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}
steps:
- name: Check out the repo
uses: actions/checkout@v2

- name: Login to Docker
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}
tag-latest: false

- name: Build and push container image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ steps.docker_meta.outputs.tags }}
file: ./Dockerfile

0 comments on commit 03e1a7a

Please sign in to comment.