forked from wazuh/wazuh-docker
Clarify 'reference' variables and implement 'commit_list' parameter logic
This commit is contained in:
@@ -20,10 +20,10 @@ on:
|
|||||||
description: 'Package revision'
|
description: 'Package revision'
|
||||||
default: '1'
|
default: '1'
|
||||||
required: true
|
required: true
|
||||||
reference:
|
commit_list:
|
||||||
description: 'Dev reference'
|
description: 'Wazuh components revisions (comma-separated string list) ["indexer", "manager", "dashboard", "agent"]'
|
||||||
type: string
|
type: string
|
||||||
default: latest
|
default: '["latest", "latest", "latest", "latest"]'
|
||||||
id:
|
id:
|
||||||
description: "ID used to identify the workflow uniquely."
|
description: "ID used to identify the workflow uniquely."
|
||||||
type: string
|
type: string
|
||||||
@@ -54,10 +54,10 @@ on:
|
|||||||
default: '1'
|
default: '1'
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
reference:
|
commit_list:
|
||||||
description: 'Dev reference'
|
description: 'Wazuh components revisions (comma-separated string list) ["indexer", "manager", "dashboard", "agent"]'
|
||||||
type: string
|
type: string
|
||||||
default: latest
|
default: '["latest", "latest", "latest", "latest"]'
|
||||||
id:
|
id:
|
||||||
description: "ID used to identify the workflow uniquely."
|
description: "ID used to identify the workflow uniquely."
|
||||||
type: string
|
type: string
|
||||||
@@ -78,6 +78,7 @@ jobs:
|
|||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
WAZUH_COMPONENTS: ${{ steps.compute-outputs.outputs.WAZUH_COMPONENTS }}
|
WAZUH_COMPONENTS: ${{ steps.compute-outputs.outputs.WAZUH_COMPONENTS }}
|
||||||
|
COMMIT_LIST: ${{ steps.compute-outputs.outputs.COMMIT_LIST }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Print inputs
|
- name: Print inputs
|
||||||
@@ -96,7 +97,7 @@ jobs:
|
|||||||
echo "* products: ${{ inputs.products }}"
|
echo "* products: ${{ inputs.products }}"
|
||||||
echo "* revision: ${{ inputs.revision }}"
|
echo "* revision: ${{ inputs.revision }}"
|
||||||
echo "* dev: ${{ inputs.dev }}"
|
echo "* dev: ${{ inputs.dev }}"
|
||||||
echo "* dev reference: ${{ inputs.reference }}"
|
echo "* commit_list: ${{ inputs.commit_list }}"
|
||||||
echo "---------------------------------------------"
|
echo "---------------------------------------------"
|
||||||
|
|
||||||
- name: Set up variables
|
- name: Set up variables
|
||||||
@@ -118,6 +119,15 @@ jobs:
|
|||||||
echo "WAZUH_COMPONENTS=[\"wazuh-manager\",\"wazuh-dashboard\",\"wazuh-indexer\",\"wazuh-agent\"]" >> $GITHUB_OUTPUT
|
echo "WAZUH_COMPONENTS=[\"wazuh-manager\",\"wazuh-dashboard\",\"wazuh-indexer\",\"wazuh-agent\"]" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Set REVISIONS
|
||||||
|
if [[ "${{ inputs.commit_list }}" != "null" && "${{ inputs.commit_list }}" != "" ]]; then
|
||||||
|
COMMIT_LIST='${{ inputs.commit_list }}'
|
||||||
|
else
|
||||||
|
COMMIT_LIST='["latest", "latest", "latest", "latest"]'
|
||||||
|
fi
|
||||||
|
echo "COMMIT_LIST=$COMMIT_LIST" >> $GITHUB_OUTPUT
|
||||||
|
echo "Revision list (indexer, manager, dashboard, agent): $COMMIT_LIST"
|
||||||
|
|
||||||
package-urls:
|
package-urls:
|
||||||
name: generate package urls
|
name: generate package urls
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
@@ -164,7 +174,7 @@ jobs:
|
|||||||
WAZUH_VERSION_RAW="${{ inputs.image_tag }}"
|
WAZUH_VERSION_RAW="${{ inputs.image_tag }}"
|
||||||
WAZUH_VERSION="${WAZUH_VERSION_RAW%%-*}"
|
WAZUH_VERSION="${WAZUH_VERSION_RAW%%-*}"
|
||||||
WAZUH_MAJOR="${WAZUH_VERSION%%.*}"
|
WAZUH_MAJOR="${WAZUH_VERSION%%.*}"
|
||||||
REFERENCE="${{ inputs.reference }}"
|
COMMIT_LIST='${{ needs.setup.outputs.COMMIT_LIST }}'
|
||||||
|
|
||||||
OUTPUT_FILE="/tmp/wazuh-docker/artifact_urls_processed.yml"
|
OUTPUT_FILE="/tmp/wazuh-docker/artifact_urls_processed.yml"
|
||||||
PRESIGNED_OUTPUT_FILE="/tmp/wazuh-docker/artifact_urls_presigned.yml"
|
PRESIGNED_OUTPUT_FILE="/tmp/wazuh-docker/artifact_urls_presigned.yml"
|
||||||
@@ -174,6 +184,12 @@ jobs:
|
|||||||
: > "$OUTPUT_FILE"
|
: > "$OUTPUT_FILE"
|
||||||
: > "$PRESIGNED_OUTPUT_FILE"
|
: > "$PRESIGNED_OUTPUT_FILE"
|
||||||
|
|
||||||
|
# Extract revisions using jq
|
||||||
|
INDEXER_COMMIT=$(echo "$COMMIT_LIST" | jq -r '.[0]')
|
||||||
|
MANAGER_COMMIT=$(echo "$COMMIT_LIST" | jq -r '.[1]')
|
||||||
|
DASHBOARD_COMMIT=$(echo "$COMMIT_LIST" | jq -r '.[2]')
|
||||||
|
AGENT_COMMIT=$(echo "$COMMIT_LIST" | jq -r '.[3]')
|
||||||
|
|
||||||
# Verify if the input file exists
|
# Verify if the input file exists
|
||||||
if [ ! -f "$ARTIFACT_URLS_FILE_TEMP" ]; then
|
if [ ! -f "$ARTIFACT_URLS_FILE_TEMP" ]; then
|
||||||
echo "The input file $ARTIFACT_URLS_FILE_TEMP does not exist." >&2
|
echo "The input file $ARTIFACT_URLS_FILE_TEMP does not exist." >&2
|
||||||
@@ -194,10 +210,10 @@ jobs:
|
|||||||
line=${line//\$\{\{ env.WAZUH_VERSION \}\}/$WAZUH_VERSION}
|
line=${line//\$\{\{ env.WAZUH_VERSION \}\}/$WAZUH_VERSION}
|
||||||
|
|
||||||
# Replace component revisions
|
# Replace component revisions
|
||||||
line=${line//\$\{\{ env.INDEXER_REVISION \}\}/$REFERENCE}
|
line=${line//\$\{\{ env.INDEXER_REVISION \}\}/$INDEXER_COMMIT}
|
||||||
line=${line//\$\{\{ env.MANAGER_REVISION \}\}/$REFERENCE}
|
line=${line//\$\{\{ env.MANAGER_REVISION \}\}/$MANAGER_COMMIT}
|
||||||
line=${line//\$\{\{ env.DASHBOARD_REVISION \}\}/$REFERENCE}
|
line=${line//\$\{\{ env.DASHBOARD_REVISION \}\}/$DASHBOARD_COMMIT}
|
||||||
line=${line//\$\{\{ env.AGENT_REVISION \}\}/$REFERENCE}
|
line=${line//\$\{\{ env.AGENT_REVISION \}\}/$AGENT_COMMIT}
|
||||||
|
|
||||||
# Append the processed line to the output file
|
# Append the processed line to the output file
|
||||||
echo "$line" >> "$OUTPUT_FILE"
|
echo "$line" >> "$OUTPUT_FILE"
|
||||||
@@ -321,6 +337,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Build Wazuh images
|
- name: Build Wazuh images
|
||||||
run: |
|
run: |
|
||||||
|
COMMIT_LIST='${{ needs.setup.outputs.COMMIT_LIST }}'
|
||||||
if [[ "$IMAGE_TAG" == *"-"* ]]; then
|
if [[ "$IMAGE_TAG" == *"-"* ]]; then
|
||||||
IFS='-' read -r -a tokens <<< "$IMAGE_TAG"
|
IFS='-' read -r -a tokens <<< "$IMAGE_TAG"
|
||||||
if [ -z "${tokens[1]}" ]; then
|
if [ -z "${tokens[1]}" ]; then
|
||||||
@@ -330,13 +347,13 @@ jobs:
|
|||||||
DEV_STAGE=${tokens[1]}
|
DEV_STAGE=${tokens[1]}
|
||||||
WAZUH_VER=${tokens[0]}
|
WAZUH_VER=${tokens[0]}
|
||||||
if [ "${{ inputs.dev }}" = true ]; then
|
if [ "${{ inputs.dev }}" = true ]; then
|
||||||
./build-images.sh -v $WAZUH_VER -r $REVISION -d $DEV_STAGE -rg $IMAGE_REGISTRY -m -ref ${{ inputs.reference }} -c ${{ matrix.wazuh_component }}
|
./build-images.sh -v $WAZUH_VER -r $REVISION -d $DEV_STAGE -rg $IMAGE_REGISTRY -m -ref "$COMMIT_LIST" -c ${{ matrix.wazuh_component }}
|
||||||
else
|
else
|
||||||
./build-images.sh -v $WAZUH_VER -r $REVISION -d $DEV_STAGE -rg $IMAGE_REGISTRY -m -c ${{ matrix.wazuh_component }}
|
./build-images.sh -v $WAZUH_VER -r $REVISION -d $DEV_STAGE -rg $IMAGE_REGISTRY -m -c ${{ matrix.wazuh_component }}
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ "${{ inputs.dev }}" = true ]; then
|
if [ "${{ inputs.dev }}" = true ]; then
|
||||||
./build-images.sh -v $IMAGE_TAG -r $REVISION -rg $IMAGE_REGISTRY -m -ref ${{ inputs.reference }} -c ${{ matrix.wazuh_component }}
|
./build-images.sh -v $IMAGE_TAG -r $REVISION -rg $IMAGE_REGISTRY -m -ref "$COMMIT_LIST" -c ${{ matrix.wazuh_component }}
|
||||||
else
|
else
|
||||||
./build-images.sh -v $IMAGE_TAG -r $REVISION -rg $IMAGE_REGISTRY -m -c ${{ matrix.wazuh_component }}
|
./build-images.sh -v $IMAGE_TAG -r $REVISION -rg $IMAGE_REGISTRY -m -c ${{ matrix.wazuh_component }}
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user