Skip to content

Commit b5cbfb5

Browse files
pipeline
1 parent 3d133b5 commit b5cbfb5

1 file changed

Lines changed: 87 additions & 0 deletions

File tree

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Build and Push Docker Images
2+
3+
on:
4+
push:
5+
branches: [main, dev, demo, hotfix]
6+
pull_request:
7+
branches: [main, dev, demo, hotfix]
8+
types: [opened, ready_for_review, reopened, synchronize]
9+
workflow_dispatch:
10+
11+
jobs:
12+
build-and-push:
13+
runs-on: ubuntu-latest
14+
env:
15+
ACR_LOGIN_SERVER: ${{ secrets.ACR_LOGIN_SERVER }}
16+
ACR_USERNAME: ${{ secrets.ACR_USERNAME }}
17+
ACR_PASSWORD: ${{ secrets.ACR_PASSWORD }}
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v2
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v1
25+
26+
- name: Log in to Azure Container Registry
27+
if: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'hotfix' }}
28+
uses: azure/docker-login@v2
29+
with:
30+
login-server: ${{ env.ACR_LOGIN_SERVER }}
31+
username: ${{ env.ACR_USERNAME }}
32+
password: ${{ env.ACR_PASSWORD }}
33+
34+
- name: Set Docker image tag
35+
run: |
36+
echo "Determining tag for branch: ${{ github.ref }}"
37+
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
38+
echo "TAG=latest" >> $GITHUB_ENV
39+
elif [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then
40+
echo "TAG=dev" >> $GITHUB_ENV
41+
elif [[ "${{ github.ref }}" == "refs/heads/demo" ]]; then
42+
echo "TAG=demo" >> $GITHUB_ENV
43+
elif [[ "${{ github.ref }}" == "refs/heads/hotfix" ]]; then
44+
echo "TAG=hotfix" >> $GITHUB_ENV
45+
else
46+
echo "TAG=pullrequest-ignore" >> $GITHUB_ENV
47+
fi
48+
echo "Tag set to: $TAG"
49+
50+
- name: Build and push ContentProcessor Docker image
51+
run: |
52+
cd src/ContentProcessor
53+
IMAGE_NAME="$ACR_LOGIN_SERVER/contentprocessor:${TAG}"
54+
echo "Using image name: ${IMAGE_NAME}"
55+
docker build -t ${IMAGE_NAME} -f .devcontainer/Dockerfile .
56+
if [[ "${TAG}" == "latest" || "${TAG}" == "dev" || "${TAG}" == "demo" || "${TAG}" == "hotfix" ]]; then
57+
docker push ${IMAGE_NAME}
58+
echo "ContentProcessor image built and pushed successfully."
59+
else
60+
echo "Skipping Docker push for ContentProcessor with tag: ${TAG}"
61+
fi
62+
63+
- name: Build and push ContentProcessorAPI Docker image
64+
run: |
65+
cd src/ContentProcessorAPI
66+
IMAGE_NAME="$ACR_LOGIN_SERVER/contentprocessorapi:${TAG}"
67+
echo "Using image name: ${IMAGE_NAME}"
68+
docker build -t ${IMAGE_NAME} -f .devcontainer/Dockerfile .
69+
if [[ "${TAG}" == "latest" || "${TAG}" == "dev" || "${TAG}" == "demo" || "${TAG}" == "hotfix" ]]; then
70+
docker push ${IMAGE_NAME}
71+
echo "ContentProcessorAPI image built and pushed successfully."
72+
else
73+
echo "Skipping Docker push for ContentProcessorAPI with tag: ${TAG}"
74+
fi
75+
76+
- name: Build and push ContentProcessorWeb Docker image
77+
run: |
78+
cd src/ContentProcessorWeb
79+
IMAGE_NAME="$ACR_LOGIN_SERVER/contentprocessorweb:${TAG}"
80+
echo "Using image name: ${IMAGE_NAME}"
81+
docker build -t ${IMAGE_NAME} -f .devcontainer/base.Dockerfile .
82+
if [[ "${TAG}" == "latest" || "${TAG}" == "dev" || "${TAG}" == "demo" || "${TAG}" == "hotfix" ]]; then
83+
docker push ${IMAGE_NAME}
84+
echo "ContentProcessorWeb image built and pushed successfully."
85+
else
86+
echo "Skipping Docker push for ContentProcessorWeb with tag: ${TAG}"
87+
fi

0 commit comments

Comments
 (0)