Skip to content

Commit 3615f9b

Browse files
committed
fix: rollback the CI change and debug the commit hash issue
1 parent 5747870 commit 3615f9b

File tree

2 files changed

+16
-56
lines changed

2 files changed

+16
-56
lines changed

.github/workflows/stage-3-build-images.yaml

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -29,35 +29,6 @@ on:
2929
required: true
3030
type: string
3131

32-
workflow_dispatch: # Added for manual triggers
33-
inputs:
34-
environment_tag:
35-
description: Environment of the deployment
36-
required: true
37-
type: string
38-
default: development
39-
docker_compose_file:
40-
description: The path of the compose.yaml file needed to build docker images
41-
required: true
42-
type: string
43-
function_app_source_code_path:
44-
description: The source path of the function app source code for the docker builds
45-
required: true
46-
type: string
47-
project_name:
48-
description: The name of the project
49-
required: true
50-
type: string
51-
excluded_containers_csv_list:
52-
description: Excluded containers in a comma separated list
53-
required: true
54-
type: string
55-
build_all_containers: # New input for manual "build all"
56-
description: Manual build for ALL containers defined in compose files
57-
required: false
58-
type: boolean
59-
default: false
60-
6132
jobs:
6233
get-functions:
6334
runs-on: ubuntu-latest
@@ -84,13 +55,9 @@ jobs:
8455
- name: Determine which Docker container(s) to build
8556
id: get-function-names
8657
env:
87-
# Conditionally source inputs based on trigger type
88-
COMPOSE_FILES_CSV: ${{ (github.event_name == 'workflow_call' && inputs.docker_compose_file) || github.event.inputs.docker_compose_file }}
89-
EXCLUDED_CONTAINERS_CSV: ${{ (github.event_name == 'workflow_call' && inputs.excluded_containers_csv_list) || github.event.inputs.excluded_containers_csv_list }}
90-
SOURCE_CODE_PATH: ${{ (github.event_name == 'workflow_call' && inputs.function_app_source_code_path) || github.event.inputs.function_app_source_code_path }}
91-
# Pass manual flag to script; defaults to 'false' if not a workflow_dispatch or if input not set
92-
BUILD_ALL_CONTAINERS: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.build_all_containers) || 'false' }}
93-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
COMPOSE_FILES_CSV: ${{ inputs.docker_compose_file }}
59+
EXCLUDED_CONTAINERS_CSV: ${{ inputs.excluded_containers_csv_list }}
60+
SOURCE_CODE_PATH: ${{ inputs.function_app_source_code_path }}
9461
run: bash ./templates/scripts/deployments/get-docker-names.sh
9562

9663
build-and-push:
@@ -136,8 +103,7 @@ jobs:
136103
- name: Create Tags
137104
env:
138105
GH_TOKEN: ${{ github.token }}
139-
# Conditionally source environment_tag
140-
ENVIRONMENT_TAG: ${{ (github.event_name == 'workflow_call' && inputs.environment_tag) || github.event.inputs.environment_tag }}
106+
ENVIRONMENT_TAG: ${{ inputs.environment_tag }}
141107
continue-on-error: false
142108
run: |
143109
echo "The branch is: ${GITHUB_REF}"
@@ -164,9 +130,8 @@ jobs:
164130
working-directory: ${{ steps.get-function-names.outputs.DOCKER_COMPOSE_DIR }}
165131
continue-on-error: false
166132
env:
167-
# Conditionally source inputs
168-
COMPOSE_FILE: ${{ (github.event_name == 'workflow_call' && inputs.docker_compose_file) || github.event.inputs.docker_compose_file }}
169-
PROJECT_NAME: ${{ (github.event_name == 'workflow_call' && inputs.project_name) || github.event.inputs.project_name }}
133+
COMPOSE_FILE: ${{ inputs.docker_compose_file }}
134+
PROJECT_NAME: ${{ inputs.project_name }}
170135
run: |
171136
function=${{ matrix.function }}
172137
echo PROJECT_NAME: ${PROJECT_NAME}
@@ -310,8 +275,7 @@ jobs:
310275
env:
311276
ACR_NAME: ${{ secrets.ACR_NAME }}
312277
SHORT_COMMIT_HASH: ${{ needs.build-and-push.outputs.short_commit_hash }}
313-
# Conditionally source environment_tag
314-
ENVIRONMENT_TAG: ${{ (github.event_name == 'workflow_call' && inputs.environment_tag) || github.event.inputs.environment_tag }}
278+
ENVIRONMENT_TAG: ${{ inputs.environment_tag }}
315279
run: bash ./templates/scripts/deployments/append-commit-hash.sh
316280

317281
aggregate-json:

scripts/deployments/get-docker-names.sh

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
#!/bin/bash
22

3-
set -eo pipefail
3+
# Exit immediately if a command exits with a non-zero status.
4+
set -e
5+
# Treat unset variables as an error when substituting.
6+
set -u
7+
# Pipestatus: if any command in a pipeline fails, the return status is that of the failed command.
8+
set -o pipefail
9+
# Print each command to stderr before executing.
10+
set -x
411

512
remove_from_array() {
613
local item_to_remove="$1"
@@ -41,12 +48,6 @@ echo -e "\nChanged source code folder(s):"
4148
printf " - %s\n" "${source_changes[@]}"
4249
echo
4350

44-
# If BUILD_ALL_CONTAINERS is true
45-
if [[ "${BUILD_ALL_CONTAINERS,,}" == "true" ]]; then
46-
echo "BUILD_ALL_CONTAINERS is true. Change detection based on specific folders will be skipped; all services will be included."
47-
source_changes=()
48-
fi
49-
5051
[[ -n "${EXCLUDED_CONTAINERS_CSV}" ]] && EXCLUSION_FILTER="select($(echo "${EXCLUDED_CONTAINERS_CSV}" | awk -v ORS='' '{split($0, arr, ","); for (i in arr) printf ".container_name != \"%s\" and ", arr[i]} END {print "1"}')) |"
5152

5253
IFS_OLD=$IFS
@@ -104,12 +105,7 @@ for compose_file in ${COMPOSE_FILES_CSV}; do
104105
echo
105106

106107
# STEP 2 - Now check the source code changes against the map created in STEP 1 to determine which containers to build
107-
if [[ "${BUILD_ALL_CONTAINERS,,}" == "true" ]]; then
108-
echo "BUILD_ALL_CONTAINERS: Adding all services from '${compose_file}'."
109-
for key in "${!docker_services_map[@]}"; do
110-
changed_services+=("${docker_services_map[$key]}")
111-
done
112-
elif [[ ${#source_changes[@]} -eq 0 ]]; then
108+
if [[ ${#source_changes[@]} -eq 0 ]]; then
113109
echo "No files changed."
114110

115111
elif [[ "${source_changes[*],,}" =~ shared ]]; then

0 commit comments

Comments
 (0)