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 12, 2024
1 parent 3c83f06 commit 0017d8c
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/image-push-master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "Push images on merge to master"
on:
push:
branches:
- master
jobs:
build-and-push-image:
runs-on: ubuntu-20.04
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}
steps:
- name: Check out the repo
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

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

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

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

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

- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: ${{ env.IMAGE_NAME }}
tag-latest: false

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

0 comments on commit 0017d8c

Please sign in to comment.