-
Notifications
You must be signed in to change notification settings - Fork 53
64 lines (52 loc) · 1.66 KB
/
build-and-publish-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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: Build and publish Docker image
on:
push:
branches:
- master
- dev
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get current app version
run: |
echo "VERSION=$(grep "__version__ =" Squest/version.py |awk '{printf $3}' | sed -e 's/^"//' -e 's/"$//')" >> $GITHUB_ENV
- name: Print app version
run: |
echo ${{ env.VERSION }}
- name: Extract Branch Name
run: echo "BRANCH=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
- name: Print branch name
run: |
echo ${{ env.BRANCH }}
- name: Set the image tag name following the branch name
run: |
if [[ ${{ env.BRANCH }} == "master" ]]; then
echo "TAG_NAME=latest" >> $GITHUB_ENV
else
echo "TAG_NAME=dev" >> $GITHUB_ENV
fi
- name: Print tag name
run: |
echo ${{ env.TAG_NAME }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Quay.io
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
- name: Build and push Squest image
uses: docker/build-push-action@v2
with:
context: .
file: docker/squest.Dockerfile
push: true
tags: |
quay.io/hewlettpackardenterprise/squest:${{ env.VERSION }}
quay.io/hewlettpackardenterprise/squest:${{ env.TAG_NAME }}