Skip to content

Commit

Permalink
ci: update dockerize workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
just-pthai-it committed Oct 10, 2024
1 parent 567844c commit 26ecde8
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 1 deletion.
27 changes: 26 additions & 1 deletion .github/workflows/dockerize-and-deploy-app_development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/scripts/generate-services-matrix.sh
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions .run/build image-dev.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="build image-dev" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
<deployment type="dockerfile">
<settings>
<option name="imageTag" value="utconnect-docs:dev-v1" />
<option name="buildArgs">
<list>
<DockerEnvVarImpl>
<option name="name" value="service_name" />
<option name="value" value="docs" />
</DockerEnvVarImpl>
</list>
</option>
<option name="buildCliOptions" value="--progress=plain" />
<option name="buildOnly" value="true" />
<option name="sourceFilePath" value="Dockerfile-development" />
</settings>
</deployment>
<method v="2" />
</configuration>
</component>

0 comments on commit 26ecde8

Please sign in to comment.