diff --git a/.github/workflows/dockerize-and-deploy-app_development.yml b/.github/workflows/dockerize-and-deploy-app_development.yml index 4a127fb..5719a69 100644 --- a/.github/workflows/dockerize-and-deploy-app_development.yml +++ b/.github/workflows/dockerize-and-deploy-app_development.yml @@ -7,9 +7,32 @@ on: - development jobs: + Define-services-matrix: + runs-on: ubuntu-latest + environment: development + outputs: + services-matrix: ${{ steps.generate-matrix.outputs.matrix }} + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Generate matrix data + id: generate-matrix + run: | + ./.github/workflows/scripts/generate-services-matrix.sh + shell: bash + + - name: Output matrix data + run: | + echo "Matrix: ${{ steps.generate-matrix.outputs.matrix }}" + Build-image: + needs: Define-services-matrix runs-on: ubuntu-latest environment: development + strategy: + matrix: + service: ${{ fromJSON(needs.Define-services-matrix.outputs.services-matrix) }} steps: - name: Check out repository code uses: actions/checkout@v4 @@ -31,7 +54,9 @@ jobs: with: file: Dockerfile-development push: true - tags: ${{ vars.DOCKERHUB_USERNAME }}/utctss-mss:dev-v1 + tags: ${{ vars.DOCKERHUB_USERNAME }}/utconnect-${{ matrix.service.service-name }}:dev-v1 + build-args: | + service_name=${{ matrix.service.service-name }} # Deploy-app: # needs: diff --git a/.github/workflows/scripts/generate-services-matrix.sh b/.github/workflows/scripts/generate-services-matrix.sh new file mode 100755 index 0000000..21bfd35 --- /dev/null +++ b/.github/workflows/scripts/generate-services-matrix.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Set the root directory where the services are located +SERVICES_DIR="./services" + +# Initialize an empty matrix array +MATRIX="[" + +# Loop through each subfolder in the 'services' directory +for SERVICE in $(ls -d ${SERVICES_DIR}/*/); do + # Extract the folder name without the path + SERVICE_NAME=$(basename $SERVICE) + + # Append to the matrix JSON object + MATRIX+="{\"service-name\": \"$SERVICE_NAME\"}," +done + +# Remove the last comma and close the JSON array +MATRIX=${MATRIX%,} +MATRIX+="]" + +# Output the matrix in the format that GitHub Actions expects using Environment Files +echo "matrix=$MATRIX" >> $GITHUB_OUTPUT diff --git a/.run/build image-dev.run.xml b/.run/build image-dev.run.xml new file mode 100644 index 0000000..2f5f139 --- /dev/null +++ b/.run/build image-dev.run.xml @@ -0,0 +1,21 @@ + + + + + + + + + + \ No newline at end of file