Skip to content

Build and push docker images for git tag #38

Build and push docker images for git tag

Build and push docker images for git tag #38

name: Build and push docker images for git tag
# Controls when the workflow will run
on:
workflow_run:
workflows: ["CodeQL"]
push:
tags:
- 'v*.*.*'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
permissions:
contents: read
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- dockerfile: ./Dockerfile
image: kennyopennix/wazuh-agent
- dockerfile: ./images/Dockerfie.amazonlinux
image: kennyopennix/wazuh-agent-amazonlinux
- dockerfile: ./images/Dockerfie.ubuntu
image: kennyopennix/wazuh-agent-ubuntu
- dockerfile: ./Dockerfile
image: opennix/wazuh-agent
- dockerfile: ./images/Dockerfie.amazonlinux
image: opennix/wazuh-agent-amazonlinux
- dockerfile: ./images/Dockerfie.ubuntu
image: opennix/wazuh-agent-ubuntu
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set Docker tag
id: vars
run: echo "tag=${GITHUB_REF#refs/*/} | sed 's/v//g'" >> $GITHUB_OUTPUT
- name: New docker image tag
run: echo "New docker image tag ${{ steps.vars.outputs.tag }}"
- name: Build and push
uses: docker/build-push-action@v5
continue-on-error: true
with:
context: .
file: ${{ matrix.dockerfile }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ matrix.image }}:${{ steps.vars.outputs.tag }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
AGENT_VERSION=${{ steps.vars.outputs.tag }}