Skip to content

Commit 822525c

Browse files
pipeline updated
1 parent 06982b7 commit 822525c

1 file changed

Lines changed: 37 additions & 30 deletions

File tree

.github/workflows/build-docker-image.yml

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -35,60 +35,67 @@ jobs:
3535
username: ${{ env.ACR_USERNAME }}
3636
password: ${{ env.ACR_PASSWORD }}
3737

38-
- name: Set Docker image tag with Date
38+
- name: Set Docker image tags
39+
id: tag
3940
run: |
40-
echo "Determining tag for branch: ${{ github.ref }}"
41-
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
42-
echo "TAG=latest-${{ steps.date.outputs.date }}" >> $GITHUB_ENV
43-
elif [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then
44-
echo "TAG=dev-${{ steps.date.outputs.date }}" >> $GITHUB_ENV
45-
elif [[ "${{ github.ref }}" == "refs/heads/demo" ]]; then
46-
echo "TAG=demo-${{ steps.date.outputs.date }}" >> $GITHUB_ENV
47-
elif [[ "${{ github.ref }}" == "refs/heads/hotfix" ]]; then
48-
echo "TAG=hotfix-${{ steps.date.outputs.date }}" >> $GITHUB_ENV
41+
BRANCH="${{ github.ref_name }}"
42+
DATE="${{ steps.date.outputs.date }}"
43+
if [[ "$BRANCH" == "main" ]]; then
44+
BASE_TAG="latest"
45+
elif [[ "$BRANCH" == "dev" ]]; then
46+
BASE_TAG="dev"
47+
elif [[ "$BRANCH" == "demo" ]]; then
48+
BASE_TAG="demo"
49+
elif [[ "$BRANCH" == "hotfix" ]]; then
50+
BASE_TAG="hotfix"
4951
else
50-
echo "TAG=pullrequest-ignore-${{ steps.date.outputs.date }}" >> $GITHUB_ENV
52+
BASE_TAG="pullrequest-ignore"
5153
fi
52-
echo "Tag set to: $TAG"
54+
DATE_TAG="${BASE_TAG}-${DATE}"
55+
echo "BASE_TAG=${BASE_TAG}" >> $GITHUB_ENV
56+
echo "DATE_TAG=${DATE_TAG}" >> $GITHUB_ENV
57+
echo "Base tag: $BASE_TAG, Date tag: $DATE_TAG"
5358
5459
- name: Build and push ContentProcessor Docker image
5560
run: |
5661
cd src/ContentProcessor
57-
IMAGE_NAME="$ACR_LOGIN_SERVER/contentprocessor:${TAG}"
62+
IMAGE_NAME="$ACR_LOGIN_SERVER/contentprocessor"
5863
echo "Using image name: ${IMAGE_NAME}"
59-
# Use the Dockerfile from the root folder of ContentProcessor
60-
docker build -t ${IMAGE_NAME} -f Dockerfile .
61-
if [[ "${TAG}" == latest-* || "${TAG}" == dev-* || "${TAG}" == demo-* || "${TAG}" == hotfix-* ]]; then
62-
docker push ${IMAGE_NAME}
64+
# Build image with two tags: one base and one with date
65+
docker build -t ${IMAGE_NAME}:${BASE_TAG} -t ${IMAGE_NAME}:${DATE_TAG} -f Dockerfile .
66+
# Push both tags if the base tag is valid
67+
if [[ "${BASE_TAG}" == "latest" || "${BASE_TAG}" == "dev" || "${BASE_TAG}" == "demo" || "${BASE_TAG}" == "hotfix" ]]; then
68+
docker push ${IMAGE_NAME}:${BASE_TAG}
69+
docker push ${IMAGE_NAME}:${DATE_TAG}
6370
echo "ContentProcessor image built and pushed successfully."
6471
else
65-
echo "Skipping Docker push for ContentProcessor with tag: ${TAG}"
72+
echo "Skipping Docker push for ContentProcessor with tag: ${BASE_TAG}"
6673
fi
6774
6875
- name: Build and push ContentProcessorAPI Docker image
6976
run: |
7077
cd src/ContentProcessorAPI
71-
IMAGE_NAME="$ACR_LOGIN_SERVER/contentprocessorapi:${TAG}"
78+
IMAGE_NAME="$ACR_LOGIN_SERVER/contentprocessorapi"
7279
echo "Using image name: ${IMAGE_NAME}"
73-
# Use the Dockerfile from the root folder of ContentProcessorAPI
74-
docker build -t ${IMAGE_NAME} -f Dockerfile .
75-
if [[ "${TAG}" == latest-* || "${TAG}" == dev-* || "${TAG}" == demo-* || "${TAG}" == hotfix-* ]]; then
76-
docker push ${IMAGE_NAME}
80+
docker build -t ${IMAGE_NAME}:${BASE_TAG} -t ${IMAGE_NAME}:${DATE_TAG} -f Dockerfile .
81+
if [[ "${BASE_TAG}" == "latest" || "${BASE_TAG}" == "dev" || "${BASE_TAG}" == "demo" || "${BASE_TAG}" == "hotfix" ]]; then
82+
docker push ${IMAGE_NAME}:${BASE_TAG}
83+
docker push ${IMAGE_NAME}:${DATE_TAG}
7784
echo "ContentProcessorAPI image built and pushed successfully."
7885
else
79-
echo "Skipping Docker push for ContentProcessorAPI with tag: ${TAG}"
86+
echo "Skipping Docker push for ContentProcessorAPI with tag: ${BASE_TAG}"
8087
fi
8188
8289
- name: Build and push ContentProcessorWeb Docker image
8390
run: |
8491
cd src/ContentProcessorWeb
85-
IMAGE_NAME="$ACR_LOGIN_SERVER/contentprocessorweb:${TAG}"
92+
IMAGE_NAME="$ACR_LOGIN_SERVER/contentprocessorweb"
8693
echo "Using image name: ${IMAGE_NAME}"
87-
# Use the Dockerfile from the root folder of ContentProcessorWeb
88-
docker build -t ${IMAGE_NAME} -f Dockerfile .
89-
if [[ "${TAG}" == latest-* || "${TAG}" == dev-* || "${TAG}" == demo-* || "${TAG}" == hotfix-* ]]; then
90-
docker push ${IMAGE_NAME}
94+
docker build -t ${IMAGE_NAME}:${BASE_TAG} -t ${IMAGE_NAME}:${DATE_TAG} -f Dockerfile .
95+
if [[ "${BASE_TAG}" == "latest" || "${BASE_TAG}" == "dev" || "${BASE_TAG}" == "demo" || "${BASE_TAG}" == "hotfix" ]]; then
96+
docker push ${IMAGE_NAME}:${BASE_TAG}
97+
docker push ${IMAGE_NAME}:${DATE_TAG}
9198
echo "ContentProcessorWeb image built and pushed successfully."
9299
else
93-
echo "Skipping Docker push for ContentProcessorWeb with tag: ${TAG}"
100+
echo "Skipping Docker push for ContentProcessorWeb with tag: ${BASE_TAG}"
94101
fi

0 commit comments

Comments
 (0)