-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (82 loc) · 3.66 KB
/
build-docker-image.yml
File metadata and controls
93 lines (82 loc) · 3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Build and Push Docker Images
on:
push:
branches: [main, dev, demo, hotfix]
pull_request:
branches: [main, dev, demo, hotfix]
types: [opened, ready_for_review, reopened, synchronize]
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
env:
ACR_LOGIN_SERVER: ${{ secrets.ACR_LOGIN_SERVER }}
ACR_USERNAME: ${{ secrets.ACR_USERNAME }}
ACR_PASSWORD: ${{ secrets.ACR_PASSWORD }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Log in to Azure Container Registry
if: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'hotfix' }}
uses: azure/docker-login@v2
with:
login-server: ${{ env.ACR_LOGIN_SERVER }}
username: ${{ env.ACR_USERNAME }}
password: ${{ env.ACR_PASSWORD }}
- name: Get registry
id: registry
run: |
echo "ext_registry=${{ env.ACR_LOGIN_SERVER || 'acrlogin.azurecr.io'}}" >> $GITHUB_OUTPUT
- name: Set Docker image tags
id: tag
run: |
BRANCH="${{ github.ref_name }}"
DATE="${{ steps.date.outputs.date }}"
GITHUB_RUN_NUMBER="${{ github.run_number }}"
if [[ "$BRANCH" == "main" ]]; then
BASE_TAG="latest"
elif [[ "$BRANCH" == "dev" ]]; then
BASE_TAG="dev"
elif [[ "$BRANCH" == "demo" ]]; then
BASE_TAG="demo"
elif [[ "$BRANCH" == "hotfix" ]]; then
BASE_TAG="hotfix"
else
BASE_TAG="pullrequest-ignore"
fi
DATE_TAG="${BASE_TAG}_${DATE}_${GITHUB_RUN_NUMBER}"
echo "BASE_TAG=${BASE_TAG}" >> $GITHUB_ENV
echo "DATE_TAG=${DATE_TAG}" >> $GITHUB_ENV
echo "Base tag: $BASE_TAG, Date tag: $DATE_TAG"
- name: Build and Push ContentProcessor Docker image
uses: docker/build-push-action@v6
with:
context: ./src/ContentProcessor
file: ./src/ContentProcessor/Dockerfile
push: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'hotfix' }}
tags: |
${{ steps.registry.outputs.ext_registry }}/contentprocessor:${{ env.BASE_TAG }}
${{ steps.registry.outputs.ext_registry }}/contentprocessor:${{ env.DATE_TAG }}
- name: Build and Push ContentProcessorAPI Docker image
uses: docker/build-push-action@v6
with:
context: ./src/ContentProcessorAPI
file: ./src/ContentProcessorAPI/Dockerfile
push: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'hotfix' }}
tags: |
${{ steps.registry.outputs.ext_registry }}/contentprocessorapi:${{ env.BASE_TAG }}
${{ steps.registry.outputs.ext_registry }}/contentprocessorapi:${{ env.DATE_TAG }}
- name: Build and Push ContentProcessorWeb Docker image
uses: docker/build-push-action@v6
with:
context: ./src/ContentProcessorWeb
file: ./src/ContentProcessorWeb/Dockerfile
push: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'hotfix' }}
tags: |
${{ steps.registry.outputs.ext_registry }}/contentprocessorweb:${{ env.BASE_TAG }}
${{ steps.registry.outputs.ext_registry }}/contentprocessorweb:${{ env.DATE_TAG }}