mirror of
https://github.com/wazuh/wazuh-docker.git
synced 2025-10-23 04:51:57 +00:00
160 lines
5.2 KiB
YAML
160 lines
5.2 KiB
YAML
run-name: Launch Push Docker Images - ${{ inputs.id }}
|
|
name: Push Docker Images
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
image_tag:
|
|
description: 'Docker image tag'
|
|
default: '5.0.0'
|
|
required: true
|
|
docker_reference:
|
|
description: 'wazuh-docker reference'
|
|
required: true
|
|
products:
|
|
description: 'Comma-separated list of the image names to build and push'
|
|
default: 'wazuh-manager,wazuh-dashboard,wazuh-indexer,wazuh-agent'
|
|
required: true
|
|
filebeat_module_version:
|
|
description: 'Filebeat module version'
|
|
default: '0.4'
|
|
required: true
|
|
revision:
|
|
description: 'Package revision'
|
|
default: '1'
|
|
required: true
|
|
push_images:
|
|
description: 'Push images'
|
|
type: boolean
|
|
default: true
|
|
required: true
|
|
id:
|
|
description: "ID used to identify the workflow uniquely."
|
|
type: string
|
|
required: false
|
|
dev:
|
|
description: "Add tag suffix '-dev' to the image tag ?"
|
|
type: boolean
|
|
default: true
|
|
required: false
|
|
workflow_call:
|
|
inputs:
|
|
image_tag:
|
|
description: 'Docker image tag'
|
|
default: '5.0.0'
|
|
required: true
|
|
type: string
|
|
docker_reference:
|
|
description: 'wazuh-docker reference'
|
|
required: false
|
|
type: string
|
|
products:
|
|
description: 'Comma-separated list of the image names to build and push'
|
|
default: 'wazuh-manager,wazuh-dashboard,wazuh-indexer,wazuh-agent'
|
|
required: true
|
|
type: string
|
|
filebeat_module_version:
|
|
description: 'Filebeat module version'
|
|
default: '0.4'
|
|
required: true
|
|
type: string
|
|
revision:
|
|
description: 'Package revision'
|
|
default: '1'
|
|
required: true
|
|
type: string
|
|
push_images:
|
|
description: 'Push images'
|
|
type: boolean
|
|
default: true
|
|
required: true
|
|
id:
|
|
description: "ID used to identify the workflow uniquely."
|
|
type: string
|
|
required: false
|
|
dev:
|
|
description: "Add tag suffix '-dev' to the image tag ?"
|
|
type: boolean
|
|
default: false
|
|
required: false
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-22.04
|
|
|
|
steps:
|
|
- name: Print inputs
|
|
run: |
|
|
echo "---------------------------------------------"
|
|
echo "Running Procedure_push_docker_images workflow"
|
|
echo "---------------------------------------------"
|
|
echo "* BRANCH: ${{ github.ref }}"
|
|
echo "* COMMIT: ${{ github.sha }}"
|
|
echo "---------------------------------------------"
|
|
echo "Inputs provided:"
|
|
echo "---------------------------------------------"
|
|
echo "* id: ${{ inputs.id }}"
|
|
echo "* image_tag: ${{ inputs.image_tag }}"
|
|
echo "* docker_reference: ${{ inputs.docker_reference }}"
|
|
echo "* products: ${{ inputs.products }}"
|
|
echo "* filebeat_module_version: ${{ inputs.filebeat_module_version }}"
|
|
echo "* revision: ${{ inputs.revision }}"
|
|
echo "* push_images: ${{ inputs.push_images }}"
|
|
echo "* dev: ${{ inputs.dev }}"
|
|
echo "---------------------------------------------"
|
|
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ inputs.docker_reference }}
|
|
|
|
- name: Log in to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
|
|
- name: Build Wazuh images
|
|
run: |
|
|
IMAGE_TAG=${{ inputs.image_tag }}
|
|
FILEBEAT_MODULE_VERSION=${{ inputs.filebeat_module_version }}
|
|
REVISION=${{ inputs.revision }}
|
|
|
|
if [[ "$IMAGE_TAG" == *"-"* ]]; then
|
|
IFS='-' read -r -a tokens <<< "$IMAGE_TAG"
|
|
if [ -z "${tokens[1]}" ]; then
|
|
echo "Invalid image tag: $IMAGE_TAG"
|
|
exit 1
|
|
fi
|
|
DEV_STAGE=${tokens[1]}
|
|
WAZUH_VER=${tokens[0]}
|
|
./build-docker-images/build-images.sh -v $WAZUH_VER -r $REVISION -d $DEV_STAGE -f $FILEBEAT_MODULE_VERSION
|
|
else
|
|
./build-docker-images/build-images.sh -v $IMAGE_TAG -r $REVISION -f $FILEBEAT_MODULE_VERSION
|
|
fi
|
|
|
|
# Save .env file (generated by build-images.sh) contents to $GITHUB_ENV
|
|
ENV_FILE_PATH=".env"
|
|
|
|
if [ -f $ENV_FILE_PATH ]; then
|
|
while IFS= read -r line || [ -n "$line" ]; do
|
|
echo "$line" >> $GITHUB_ENV
|
|
done < $ENV_FILE_PATH
|
|
else
|
|
echo "The environment file $ENV_FILE_PATH does not exist!"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Tag and Push Wazuh images
|
|
if: ${{ inputs.push_images }}
|
|
run: |
|
|
IMAGE_TAG="${{ inputs.image_tag }}$( [ "${{ inputs.dev }}" == "true" ] && echo '-dev' || true )"
|
|
IMAGE_NAMES=${{ inputs.products }}
|
|
IFS=',' read -r -a images <<< "$IMAGE_NAMES"
|
|
for image in "${images[@]}"; do
|
|
echo "Tagging and pushing wazuh/$image:${WAZUH_VERSION} to wazuh/$image:$IMAGE_TAG"
|
|
docker tag wazuh/$image:${WAZUH_VERSION} wazuh/$image:$IMAGE_TAG
|
|
echo "Pushing wazuh/$image:$IMAGE_TAG ..."
|
|
docker push wazuh/$image:$IMAGE_TAG
|
|
done
|