From 027b26047f6bc862329e880b75b1c6c9c86955d9 Mon Sep 17 00:00:00 2001 From: "JESUS D. GARCIA" Date: Mon, 30 Sep 2024 16:20:31 -0500 Subject: [PATCH 1/2] Update Procedure_push_docker_images.yml --- .../Procedure_push_docker_images.yml | 101 +++++++++++++----- 1 file changed, 77 insertions(+), 24 deletions(-) diff --git a/.github/workflows/Procedure_push_docker_images.yml b/.github/workflows/Procedure_push_docker_images.yml index 79a813df..c27ae5d0 100644 --- a/.github/workflows/Procedure_push_docker_images.yml +++ b/.github/workflows/Procedure_push_docker_images.yml @@ -1,33 +1,84 @@ -run-name: Launch Push Docker Images - Executed by @${{ github.actor }} +run-name: Launch Push Docker Images - ${{ inputs.id }} name: Push Docker Images on: workflow_dispatch: inputs: - IMAGE_TAG: + image_tag: description: 'Docker image tag' default: '4.10.0' required: true - DOCKER_REFERENCE: + docker_reference: description: 'wazuh-docker reference' default: 'v4.10.0' + required: false + products: + description: 'Comma-separated list of the image names to build and push' + default: 'wazuh-manager,wazuh-dashboard,wazuh-indexer' + 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 - PRODUCTS: + 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 + workflow_call: + inputs: + image_tag: + description: 'Docker image tag' + default: '4.10.0' + required: true + type: string + docker_reference: + description: 'wazuh-docker reference' + default: 'v4.10.0' + required: false + type: string + products: description: 'Comma-separated list of the image names to build and push' default: 'wazuh-manager,wazuh-dashboard,wazuh-indexer' required: true - FILEBEAT_MODULE_VERSION: + type: string + filebeat_module_version: description: 'Filebeat module version' + default: '0.4' required: true - REVISION: + type: string + revision: description: 'Package revision' default: '1' required: true - PUSH_IMAGES: + 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: @@ -44,23 +95,25 @@ jobs: echo "---------------------------------------------" echo "Inputs provided:" echo "---------------------------------------------" - 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 "* 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 }} + ref: ${{ inputs.docker_reference }} - name: Log in to Docker Hub uses: docker/login-action@v3 with: - username: wazuh + username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Install Docker Compose @@ -71,10 +124,9 @@ jobs: - name: Build Wazuh images run: | - IMAGE_TAG=${{ inputs.IMAGE_TAG }} - FILEBEAT_MODULE_VERSION=${{ inputs.FILEBEAT_MODULE_VERSION }} - REVISION=${{ inputs.REVISION }} - PUSH_IMAGES=${{ inputs.PUSH_IMAGES }} + 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" @@ -89,8 +141,9 @@ jobs: ./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" - # Save .env file contents to $GITHUB_ENV + if [ -f $ENV_FILE_PATH ]; then while IFS= read -r line || [ -n "$line" ]; do echo "$line" >> $GITHUB_ENV @@ -100,15 +153,15 @@ jobs: exit 1 fi - - name: Tag and Push Wazuh images - if: ${{ inputs.PUSH_IMAGES }} + if: ${{ inputs.push_images }} run: | - IMAGE_TAG=${{ inputs.IMAGE_TAG }} - IMAGE_NAMES=${{ inputs.PRODUCTS }} + 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 From 8bafe1295b4314fa55043bd81df83a5632806736 Mon Sep 17 00:00:00 2001 From: "JESUS D. GARCIA" Date: Tue, 1 Oct 2024 10:06:13 -0500 Subject: [PATCH 2/2] Change the dev default value to true for the workflow_dispatch --- .github/workflows/Procedure_push_docker_images.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Procedure_push_docker_images.yml b/.github/workflows/Procedure_push_docker_images.yml index c27ae5d0..7ff8033d 100644 --- a/.github/workflows/Procedure_push_docker_images.yml +++ b/.github/workflows/Procedure_push_docker_images.yml @@ -36,7 +36,7 @@ on: dev: description: "Add tag suffix '-dev' to the image tag ?" type: boolean - default: false + default: true required: false workflow_call: inputs: