-
Notifications
You must be signed in to change notification settings - Fork 1
46 lines (40 loc) · 1.3 KB
/
02-build-docker-image.yml
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
name: Build docker image with appropriate tag
on:
push:
branches:
- develop
release:
types: [released]
jobs:
build_docker_image:
runs-on: ubuntu-22.04
steps:
- name: Determine Docker Tag
id: docker_tag
run: |
GIT_EVENT=${{ github.event_name }}
GIT_BRANCH_NAME=${GITHUB_REF##*/}
if [[ $GIT_EVENT == 'push' && $GIT_BRANCH_NAME == 'develop' ]]; then
echo "DOCKER_TAG=latest" >> $GITHUB_ENV
elif [[ $GIT_EVENT == 'release' ]]; then
GIT_TAG_NAME=${{ github.event.release.tag_name }}
echo "DOCKER_TAG=$(echo $GIT_TAG_NAME | cut -c 2-)" >> $GITHUB_ENV
fi
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to Artifactory
uses: docker/login-action@v2
with:
registry: ${{ secrets.DOCKER_REPOSITORY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build image and push to Artifactory
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: |
${{ secrets.DOCKER_REPOSITORY_LOCAL }}:${{ env.DOCKER_TAG }}