@@ -35,60 +35,54 @@ 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+ GITHUB_RUN_NUMBER="${{ github.run_number }}"
44+ if [[ "$BRANCH" == "main" ]]; then
45+ BASE_TAG="latest"
46+ elif [[ "$BRANCH" == "dev" ]]; then
47+ BASE_TAG="dev"
48+ elif [[ "$BRANCH" == "demo" ]]; then
49+ BASE_TAG="demo"
50+ elif [[ "$BRANCH" == "hotfix" ]]; then
51+ BASE_TAG="hotfix"
4952 else
50- echo "TAG= pullrequest-ignore-${{ steps.date.outputs.date }}" >> $GITHUB_ENV
53+ BASE_TAG=" pullrequest-ignore"
5154 fi
52- echo "Tag set to: $TAG"
55+ DATE_TAG="${BASE_TAG}_${DATE}_${GITHUB_RUN_NUMBER}"
56+ echo "BASE_TAG=${BASE_TAG}" >> $GITHUB_ENV
57+ echo "DATE_TAG=${DATE_TAG}" >> $GITHUB_ENV
58+ echo "Base tag: $BASE_TAG, Date tag: $DATE_TAG"
5359
54- - name : Build and push ContentProcessor Docker image
55- run : |
56- cd src/ContentProcessor
57- IMAGE_NAME="$ACR_LOGIN_SERVER/contentprocessor:${TAG}"
58- 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}
63- echo "ContentProcessor image built and pushed successfully."
64- else
65- echo "Skipping Docker push for ContentProcessor with tag: ${TAG}"
66- fi
60+ - name : Build and Push ContentProcessor Docker image
61+ uses : docker/build-push-action@v6
62+ with :
63+ context : ./src/ContentProcessor
64+ file : ./src/ContentProcessor/Dockerfile
65+ push : ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'hotfix' }}
66+ tags : |
67+ ${{ env.ACR_LOGIN_SERVER }}/contentprocessor:${{ env.BASE_TAG }}
68+ ${{ env.ACR_LOGIN_SERVER }}/contentprocessor:${{ env.DATE_TAG }}
6769
68- - name : Build and push ContentProcessorAPI Docker image
69- run : |
70- cd src/ContentProcessorAPI
71- IMAGE_NAME="$ACR_LOGIN_SERVER/contentprocessorapi:${TAG}"
72- 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}
77- echo "ContentProcessorAPI image built and pushed successfully."
78- else
79- echo "Skipping Docker push for ContentProcessorAPI with tag: ${TAG}"
80- fi
70+ - name : Build and Push ContentProcessorAPI Docker image
71+ uses : docker/build-push-action@v6
72+ with :
73+ context : ./src/ContentProcessorAPI
74+ file : ./src/ContentProcessorAPI/Dockerfile
75+ push : ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'hotfix' }}
76+ tags : |
77+ ${{ env.ACR_LOGIN_SERVER }}/contentprocessorapi:${{ env.BASE_TAG }}
78+ ${{ env.ACR_LOGIN_SERVER }}/contentprocessorapi:${{ env.DATE_TAG }}
8179
82- - name : Build and push ContentProcessorWeb Docker image
83- run : |
84- cd src/ContentProcessorWeb
85- IMAGE_NAME="$ACR_LOGIN_SERVER/contentprocessorweb:${TAG}"
86- 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}
91- echo "ContentProcessorWeb image built and pushed successfully."
92- else
93- echo "Skipping Docker push for ContentProcessorWeb with tag: ${TAG}"
94- fi
80+ - name : Build and Push ContentProcessorWeb Docker image
81+ uses : docker/build-push-action@v6
82+ with :
83+ context : ./src/ContentProcessorWeb
84+ file : ./src/ContentProcessorWeb/Dockerfile
85+ push : ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'hotfix' }}
86+ tags : |
87+ ${{ env.ACR_LOGIN_SERVER }}/contentprocessorweb:${{ env.BASE_TAG }}
88+ ${{ env.ACR_LOGIN_SERVER }}/contentprocessorweb:${{ env.DATE_TAG }}
0 commit comments