Skip to content

feat(ci): automatically build and push container images #1

feat(ci): automatically build and push container images

feat(ci): automatically build and push container images #1

name: Publish Container Images
on:
push:
tags: [ 'v*' ]
jobs:
publish-containers:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set version number
run: |
echo "VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
echo "DOCKER_REPOSITORY=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push controller
uses: docker/build-push-action@v2
with:
context: ./hairpin-proxy-controller
push: true
build-args: version=${{ env.VERSION }}
tags: |
ghcr.io/${{ env.DOCKER_REPOSITORY }}/controller:latest
ghcr.io/${{ env.DOCKER_REPOSITORY }}/controller:${{ env.VERSION }}
cache-from: type=registry,ref=ghcr.io/${{ env.DOCKER_REPOSITORY }}/controller:latest
cache-to: type=inline
- name: Build and push haproxy
uses: docker/build-push-action@v2
with:
context: ./hairpin-proxy-haproxy
push: true
build-args: version=${{ env.VERSION }}
tags: |
ghcr.io/${{ env.DOCKER_REPOSITORY }}/haproxy:latest
ghcr.io/${{ env.DOCKER_REPOSITORY }}/haproxy:${{ env.VERSION }}
cache-from: type=registry,ref=ghcr.io/${{ env.DOCKER_REPOSITORY }}/haproxy:latest
cache-to: type=inline