Add GitHub Actions workflow for building and pushing Docker container

This commit is contained in:
Sofiane Gerhardt 2024-12-02 10:45:59 +01:00
commit b6c250540a
Signed by: sofiane.gerhardt
SSH key fingerprint: SHA256:B+mV6AyYLX4aUI1b5gXcuADKOT8LepFIxknwPyd26f0
3 changed files with 112 additions and 0 deletions

View file

@ -0,0 +1,48 @@
name: Build and Push container
run-name: Build and Push container
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
env:
IMAGE: git.kvant.cloud/phoenix/metricbeat-hpc
VERSION: ${{ github.ref_name }}
jobs:
build_besu:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to gitea registry
uses: docker/login-action@v3
with:
registry: git.kvant.cloud
username: ${{ vars.PHOENIX_PACKAGE_WRITER_USERNAME }}
password: ${{ secrets.PHOENIX_PACKAGE_WRITER_TOKEN }}
- name: Update Dockerfile FROM version
run: sed -i "s|^FROM .\+|FROM docker.elastic.co/beats/metricbeat-oss:${{ env.VERSION }}|" Dockerfile
- name: Build and push to gitea registry
uses: docker/build-push-action@v6
with:
platforms: linux/s390x
push: true
context: .
build-args: |
VERSION=${{ env.VERSION }}
image: ${{ env.IMAGE }}
cache-from: |
type=registry,ref=${{ env.IMAGE }}:${{ env.VERSION }}
type=registry,ref=${{ env.IMAGE }}:latest
cache-to: type=inline
tags: |
${{ env.IMAGE }}:${{ env.VERSION }}
${{ env.IMAGE }}:latest