Skip to content

Build and push docker images #6

Build and push docker images

Build and push docker images #6

name: Build and push docker images
# Controls when the workflow will run
on:
workflow_run:
workflows: ["CodeQL"]
branches: [main]
types:
- completed
push:
branches:
- 'main'
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:
repositories: ["kennyopennix/wazuh-agent", "kennyopennix/wazuh-agent-amazonlinux", "kennyopennix/wazuh-agent-ubuntu"]
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
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
if: github.event_name != 'pull_request'
id: meta
uses: docker/metadata-action@v4
with:
images: kennyopennix/wazuh-agent
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
file: ${{ matrix.dockerfile }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Update repo description
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ matrix.repositories }}