Skip to content

Commit 9095016

Browse files
pipeline new
1 parent b5cbfb5 commit 9095016

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ jobs:
2323
- name: Set up Docker Buildx
2424
uses: docker/setup-buildx-action@v1
2525

26+
- name: Get current date
27+
id: date
28+
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
29+
2630
- name: Log in to Azure Container Registry
2731
if: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'hotfix' }}
2832
uses: azure/docker-login@v2
@@ -31,19 +35,19 @@ jobs:
3135
username: ${{ env.ACR_USERNAME }}
3236
password: ${{ env.ACR_PASSWORD }}
3337

34-
- name: Set Docker image tag
38+
- name: Set Docker image tag with Date
3539
run: |
3640
echo "Determining tag for branch: ${{ github.ref }}"
3741
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
38-
echo "TAG=latest" >> $GITHUB_ENV
42+
echo "TAG=latest-${{ steps.date.outputs.date }}" >> $GITHUB_ENV
3943
elif [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then
40-
echo "TAG=dev" >> $GITHUB_ENV
44+
echo "TAG=dev-${{ steps.date.outputs.date }}" >> $GITHUB_ENV
4145
elif [[ "${{ github.ref }}" == "refs/heads/demo" ]]; then
42-
echo "TAG=demo" >> $GITHUB_ENV
46+
echo "TAG=demo-${{ steps.date.outputs.date }}" >> $GITHUB_ENV
4347
elif [[ "${{ github.ref }}" == "refs/heads/hotfix" ]]; then
44-
echo "TAG=hotfix" >> $GITHUB_ENV
48+
echo "TAG=hotfix-${{ steps.date.outputs.date }}" >> $GITHUB_ENV
4549
else
46-
echo "TAG=pullrequest-ignore" >> $GITHUB_ENV
50+
echo "TAG=pullrequest-ignore-${{ steps.date.outputs.date }}" >> $GITHUB_ENV
4751
fi
4852
echo "Tag set to: $TAG"
4953
@@ -53,7 +57,7 @@ jobs:
5357
IMAGE_NAME="$ACR_LOGIN_SERVER/contentprocessor:${TAG}"
5458
echo "Using image name: ${IMAGE_NAME}"
5559
docker build -t ${IMAGE_NAME} -f .devcontainer/Dockerfile .
56-
if [[ "${TAG}" == "latest" || "${TAG}" == "dev" || "${TAG}" == "demo" || "${TAG}" == "hotfix" ]]; then
60+
if [[ "${TAG}" == latest-* || "${TAG}" == dev-* || "${TAG}" == demo-* || "${TAG}" == hotfix-* ]]; then
5761
docker push ${IMAGE_NAME}
5862
echo "ContentProcessor image built and pushed successfully."
5963
else
@@ -66,7 +70,7 @@ jobs:
6670
IMAGE_NAME="$ACR_LOGIN_SERVER/contentprocessorapi:${TAG}"
6771
echo "Using image name: ${IMAGE_NAME}"
6872
docker build -t ${IMAGE_NAME} -f .devcontainer/Dockerfile .
69-
if [[ "${TAG}" == "latest" || "${TAG}" == "dev" || "${TAG}" == "demo" || "${TAG}" == "hotfix" ]]; then
73+
if [[ "${TAG}" == latest-* || "${TAG}" == dev-* || "${TAG}" == demo-* || "${TAG}" == hotfix-* ]]; then
7074
docker push ${IMAGE_NAME}
7175
echo "ContentProcessorAPI image built and pushed successfully."
7276
else
@@ -79,7 +83,7 @@ jobs:
7983
IMAGE_NAME="$ACR_LOGIN_SERVER/contentprocessorweb:${TAG}"
8084
echo "Using image name: ${IMAGE_NAME}"
8185
docker build -t ${IMAGE_NAME} -f .devcontainer/base.Dockerfile .
82-
if [[ "${TAG}" == "latest" || "${TAG}" == "dev" || "${TAG}" == "demo" || "${TAG}" == "hotfix" ]]; then
86+
if [[ "${TAG}" == latest-* || "${TAG}" == dev-* || "${TAG}" == demo-* || "${TAG}" == hotfix-* ]]; then
8387
docker push ${IMAGE_NAME}
8488
echo "ContentProcessorWeb image built and pushed successfully."
8589
else

0 commit comments

Comments
 (0)