forked from wazuh/wazuh-docker
Add support for building multiple Wazuh components separately
This commit is contained in:
@@ -11,6 +11,10 @@ on:
|
||||
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
|
||||
revision:
|
||||
description: 'Package revision'
|
||||
default: '1'
|
||||
@@ -39,6 +43,11 @@ on:
|
||||
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
|
||||
revision:
|
||||
description: 'Package revision'
|
||||
default: '1'
|
||||
@@ -59,17 +68,15 @@ on:
|
||||
required: false
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
setup:
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: read
|
||||
|
||||
env:
|
||||
IMAGE_REGISTRY: ${{ inputs.dev && vars.IMAGE_REGISTRY_DEV || vars.IMAGE_REGISTRY_PROD }}
|
||||
IMAGE_TAG: ${{ inputs.image_tag }}
|
||||
REVISION: ${{ inputs.revision }}
|
||||
outputs:
|
||||
WAZUH_COMPONENTS: ${{ steps.compute-outputs.outputs.WAZUH_COMPONENTS }}
|
||||
|
||||
steps:
|
||||
- name: Print inputs
|
||||
@@ -85,11 +92,52 @@ jobs:
|
||||
echo "* id: ${{ inputs.id }}"
|
||||
echo "* image_tag: ${{ inputs.image_tag }}"
|
||||
echo "* docker_reference: ${{ inputs.docker_reference }}"
|
||||
echo "* products: ${{ inputs.products }}"
|
||||
echo "* revision: ${{ inputs.revision }}"
|
||||
echo "* dev: ${{ inputs.dev }}"
|
||||
echo "* dev reference: ${{ inputs.reference }}"
|
||||
echo "---------------------------------------------"
|
||||
|
||||
- name: Set up variables
|
||||
id: compute-outputs
|
||||
run: |
|
||||
if [[ "${{ inputs.products }}" != "null" && "${{ inputs.products }}" != "" ]]; then
|
||||
# Convert comma-separated list to JSON array format
|
||||
IFS=',' read -ra COMPONENTS <<< "${{ inputs.products }}"
|
||||
JSON_ARRAY="["
|
||||
for i in "${!COMPONENTS[@]}"; do
|
||||
if [ $i -gt 0 ]; then
|
||||
JSON_ARRAY+=","
|
||||
fi
|
||||
JSON_ARRAY+="\"${COMPONENTS[$i]}\""
|
||||
done
|
||||
JSON_ARRAY+="]"
|
||||
echo "WAZUH_COMPONENTS=$JSON_ARRAY" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "WAZUH_COMPONENTS=[\"wazuh-manager\",\"wazuh-dashboard\",\"wazuh-indexer\",\"wazuh-agent\"]" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
build-and-push:
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: read
|
||||
|
||||
needs:
|
||||
- setup
|
||||
|
||||
strategy:
|
||||
fail-fast: false # all jobs will run even if one fails
|
||||
matrix:
|
||||
wazuh_component: ${{ fromJson(needs.setup.outputs.WAZUH_COMPONENTS) }}
|
||||
|
||||
env:
|
||||
IMAGE_REGISTRY: ${{ inputs.dev && vars.IMAGE_REGISTRY_DEV || vars.IMAGE_REGISTRY_PROD }}
|
||||
IMAGE_TAG: ${{ inputs.image_tag }}
|
||||
REVISION: ${{ inputs.revision }}
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
@@ -154,7 +202,7 @@ jobs:
|
||||
run: |
|
||||
if [ "${{ inputs.dev }}" = true ]; then
|
||||
IMAGE_TAG="${{ inputs.image_tag }}-${{ inputs.reference }}"
|
||||
./build-images.sh -v ${{ inputs.image_tag }} -r $REVISION -d "dev" -rg $IMAGE_REGISTRY -m -ref ${{ inputs.reference }}
|
||||
./build-images.sh -v ${{ inputs.image_tag }} -r $REVISION -d "dev" -rg $IMAGE_REGISTRY -m -ref ${{ inputs.reference }} -c ${{ matrix.wazuh_component }}
|
||||
else
|
||||
if [[ "$IMAGE_TAG" == *"-"* ]]; then
|
||||
IFS='-' read -r -a tokens <<< "$IMAGE_TAG"
|
||||
@@ -164,9 +212,9 @@ jobs:
|
||||
fi
|
||||
DEV_STAGE=${tokens[1]}
|
||||
WAZUH_VER=${tokens[0]}
|
||||
./build-images.sh -v $WAZUH_VER -r $REVISION -d $DEV_STAGE -rg $IMAGE_REGISTRY -m
|
||||
./build-images.sh -v $WAZUH_VER -r $REVISION -d $DEV_STAGE -rg $IMAGE_REGISTRY -m -c ${{ matrix.wazuh_component }}
|
||||
else
|
||||
./build-images.sh -v $IMAGE_TAG -r $REVISION -rg $IMAGE_REGISTRY -m
|
||||
./build-images.sh -v $IMAGE_TAG -r $REVISION -rg $IMAGE_REGISTRY -m -c ${{ matrix.wazuh_component }}
|
||||
fi
|
||||
fi
|
||||
# Save .env file (generated by build-images.sh) contents to $GITHUB_ENV
|
||||
|
||||
Reference in New Issue
Block a user