Skip to content

Commit 995d053

Browse files
committed
feat/ci: Add main branch matrix
Signed-off-by: SeeuSim <[email protected]>
1 parent fa96760 commit 995d053

File tree

1 file changed

+51
-40
lines changed

1 file changed

+51
-40
lines changed

.github/workflows/build-docker.yaml

Lines changed: 51 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -44,51 +44,62 @@ jobs:
4444
- name: output-job-matrix
4545
id: set-matrix
4646
run: |
47+
is_main=${{ contains(github.ref, 'main') }}
4748
matrix=()
48-
if [[ "${{ steps.filter.outputs.user }}" == "true" ]]; then
49-
matrix+=("{
50-
\"package\": \"user\",
51-
\"image\": \"$DOCKER_REGISTRY_USN/user-express\",
52-
\"context\": \"./backend/user\",
53-
\"dockerfile\": \"./backend/user/express.Dockerfile\",
54-
\"build-args\": \"port=$USER_EXPRESS_PORT\"
55-
}")
49+
if [[ "${{ steps.filter.outputs.user }}" == "true" || "$is_main" == "true" ]]; then
50+
config=$(jq -n \
51+
--arg pkg "user" \
52+
--arg img "$DOCKER_REGISTRY_USN/user-express" \
53+
--arg ctx "./backend/user" \
54+
--arg dkr "./backend/user/express.Dockerfile" \
55+
--arg bag "port=$USER_EXPRESS_PORT" \
56+
'{package: $pkg, image: $img, context: $ctx, dockerfile: $dkr, "build-args": $bag}')
57+
)
58+
matrix+=("$config")
5659
fi
57-
if [[ "${{ steps.filter.outputs.question }}" == "true" ]]; then
58-
matrix+=("{
59-
\"package\": \"question\",
60-
\"image\": \"$DOCKER_REGISTRY_USN/question-express\",
61-
\"context\": \"./backend/question\",
62-
\"dockerfile\": \"./backend/question/express.Dockerfile\",
63-
\"build-args\": \"port=$QUESTION_EXPRESS_PORT\"
64-
}")
60+
if [[ "${{ steps.filter.outputs.question }}" == "true" || "$is_main" == "true" ]]; then
61+
config=$(jq -n \
62+
--arg pkg "question" \
63+
--arg img "$DOCKER_REGISTRY_USN/question-express" \
64+
--arg ctx "./backend/question" \
65+
--arg dkr "./backend/question/express.Dockerfile" \
66+
--arg bag "port=$QUESTION_EXPRESS_PORT" \
67+
'{package: $pkg, image: $img, context: $ctx, dockerfile: $dkr, "build-args": $bag}')
68+
)
69+
matrix+=("$config")
6570
fi
66-
if [[ "${{ steps.filter.outputs.collaboration }}" == "true" ]]; then
67-
matrix+=("{
68-
\"package\": \"collaboration\",
69-
\"image\": \"$DOCKER_REGISTRY_USN/collab-express\",
70-
\"context\": \"./backend/collaboration\",
71-
\"dockerfile\": \"./backend/collaboration/express.Dockerfile\",
72-
\"build-args\": \"port=$COLLAB_EXPRESS_PORT\"
73-
}")
71+
if [[ "${{ steps.filter.outputs.collaboration }}" == "true" || "$is_main" == "true" ]]; then
72+
config=$(jq -n \
73+
--arg pkg "collaboration" \
74+
--arg img "$DOCKER_REGISTRY_USN/collab-express" \
75+
--arg ctx "./backend/collaboration" \
76+
--arg dkr "./backend/collaboration/express.Dockerfile" \
77+
--arg bag "port=$COLLAB_EXPRESS_PORT" \
78+
'{package: $pkg, image: $img, context: $ctx, dockerfile: $dkr, "build-args": $bag}')
79+
)
80+
matrix+=("$config")
7481
fi
75-
if [[ "${{ steps.filter.outputs.matching }}" == "true" ]]; then
76-
matrix+=("{
77-
\"package\": \"matching\",
78-
\"image\": \"$DOCKER_REGISTRY_USN/match-express\",
79-
\"context\": \"./backend/matching\",
80-
\"dockerfile\": \"./backend/matching/express.Dockerfile\",
81-
\"build-args\": \"port=$MATCH_EXPRESS_PORT\"
82-
}")
82+
if [[ "${{ steps.filter.outputs.matching }}" == "true" || "$is_main" == "true" ]]; then
83+
config=$(jq -n \
84+
--arg pkg "matching" \
85+
--arg img "$DOCKER_REGISTRY_USN/match-express" \
86+
--arg ctx "./backend/matching" \
87+
--arg dkr "./backend/matching/express.Dockerfile" \
88+
--arg bag "port=$MATCH_EXPRESS_PORT" \
89+
'{package: $pkg, image: $img, context: $ctx, dockerfile: $dkr, "build-args": $bag}')
90+
)
91+
matrix+=("$config")
8392
fi
84-
if [[ "${{ steps.filter.outputs.frontend }}" == "true" ]]; then
85-
matrix+=("{
86-
\"package\": \"frontend\",
87-
\"image\": \"$DOCKER_REGISTRY_USN/frontend\",
88-
\"context\": \"./frontend\",
89-
\"dockerfile\": \"./frontend/frontend.Dockerfile\",
90-
\"build-args\": \"port=$FRONTEND_PORT\"
91-
}")
93+
if [[ "${{ steps.filter.outputs.frontend }}" == "true" || "$is_main" == "true" ]]; then
94+
config=$(jq -n \
95+
--arg pkg "frontend" \
96+
--arg img "$DOCKER_REGISTRY_USN/frontend" \
97+
--arg ctx "./frontend" \
98+
--arg dkr "./frontend/express.Dockerfile" \
99+
--arg bag "port=$FRONTEND_PORT" \
100+
'{package: $pkg, image: $img, context: $ctx, dockerfile: $dkr, "build-args": $bag}')
101+
)
102+
matrix+=("$config")
92103
fi
93104
formatted_matrix=$(echo "[${matrix[*]}]" | jq -c .)
94105
echo "Outputs Generated: $formatted_matrix"

0 commit comments

Comments
 (0)