Skip to content

Commit 745ff3c

Browse files
committed
Update build.yaml
1 parent 9f2c05a commit 745ff3c

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

.github/workflows/build.yaml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ jobs:
8383
ref: refs/tags/${{github.event.inputs.env}}
8484
- run: cd tasking-manager; echo TM_VERSION=`/usr/bin/git log -1 --format='%h'` >> "$GITHUB_ENV"
8585

86-
8786
# leaderboard submod
8887
- name: Checkout leaderboard
8988
uses: actions/checkout@v2
@@ -93,7 +92,6 @@ jobs:
9392
ref: refs/tags/${{github.event.inputs.env}}
9493
- run: cd leaderboard; echo LB_VERSION=`/usr/bin/git log -1 --format='%h'` >> "$GITHUB_ENV"
9594

96-
9795
- uses: docker/login-action@v3
9896
with:
9997
registry: ${{ vars.WS_DOCKER_REGISTRY }}
@@ -115,8 +113,24 @@ jobs:
115113

116114
- name: Build and push
117115
run: |
118-
docker compose -f docker-compose.build.yml --env-file tdei_uw.env build --build-arg CODE_VERSION=${CODE_VERSION} ${{github.event.inputs.build_flag}}
119-
docker compose -f docker-compose.build.yml --env-file tdei_uw.env push
116+
set -x
117+
118+
for JSON_CONFIG in `docker compose -f docker-compose.build.yml config --format json | jq -c '.services|to_entries[]'`;
119+
do
120+
SERVICE_NAME=`echo $JSON_CONFIG | jq -r '.key'`
121+
IMAGE_TEMPLATE=`jq -r '.value.image'`
122+
IMAGE_NAME=`echo $IMAGE_TEMPLATE | cut -d "/" -f 2 | cut -d ":" -f 1`
123+
IMAGE="$IMAGE_TEMPLATE$CODE_VERSION"
124+
125+
if az acr repository show-tags --username ${{ vars.DOCKERHUB_USERNAME }} --password ${{ secrets.DOCKERHUB_TOKEN }} --name opensidewalksdev --repository $IMAGE_NAME | grep -o $CODE_VERSION; then
126+
echo "Image already exists for $IMAGE_PATH, not building again"
127+
else
128+
echo "Image does not exist at $IMAGE_PATH, building and pushing"
129+
130+
docker compose -f docker-compose.build.yml --env-file tdei_uw.env build --build-arg CODE_VERSION=${CODE_VERSION} ${{github.event.inputs.build_flag}} $SERVICE_NAME
131+
docker compose -f docker-compose.build.yml --env-file tdei_uw.env push $SERVICE_NAME
132+
fi
133+
done
120134
121135
env:
122136
ENV: ${{ vars.ENV }}

0 commit comments

Comments
 (0)