-
Notifications
You must be signed in to change notification settings - Fork 1
100 lines (82 loc) · 2.89 KB
/
build-container.yaml
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
94
95
96
97
98
99
name: build-docker-images
on:
workflow_dispatch:
pull_request:
push:
branches:
- release-*
tags:
- '*'
paths:
- "lib/**/**"
- "src/**"
- ".github/workflows/**"
permissions:
contents: read
packages: write
jobs:
docker-builds:
strategy:
matrix:
app:
- auth
- console
#- website
include:
- app: auth
dockerFile: Dockerfile
- app: console
dockerFile: Dockerfile
#- app: website
#dockerFile: Dockerfile.devdoc
runs-on: ubuntu-latest
name: Deploy to Docker Image
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create Image Tag from branch name
if: startsWith(github.ref, 'refs/heads/release-')
run: |
set +e
IMAGE_TAG=$(echo ${GITHUB_REF#refs/heads/release-})
echo "$IMAGE_TAG" | grep -i '\-nightly$'
if [ $? -ne 0 ]; then
IMAGE_TAG="$IMAGE_TAG-nightly"
fi
set -e
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
echo "OVERRIDE_PUSHED_IMAGE=true" >> $GITHUB_ENV
- name: Create Image Tag from tag
if: startsWith(github.ref, 'refs/tags/')
run: |
IMAGE_TAG=$(echo ${GITHUB_REF#refs/tags/})
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
echo "OVERRIDE_PUSHED_IMAGE=false" >> $GITHUB_ENV
- name: Build
if: "!startsWith(github.ref, 'refs/heads/release-') && !startsWith(github.ref, 'refs/tags/')"
run: |
image_name="ghcr.io/${{ github.repository }}/${{matrix.app}}"
docker build --build-arg APP=${{matrix.app}} -f ${{matrix.dockerFile}} . -t "$image_name:test"
- name: Build & Push Image
if: startsWith(github.ref, 'refs/heads/release-') || startsWith(github.ref, 'refs/tags/')
run: |
set +e
image_name="ghcr.io/${{ github.repository }}/${{matrix.app}}"
docker manifest inspect $image_name:$IMAGE_TAG
exit_status=$?
if [ $exit_status -eq 0 ]; then
[ "$OVERRIDE_PUSHED_IMAGE" = "false" ] && echo "image ($image_name:$IMAGE_TAG) already exists, and override image is disable, exiting" && exit 0
echo "image exists, but override pushed image is set to true. proceeding with building image"
fi
set -e
docker build --build-arg APP=${{matrix.app}} -f ${{matrix.dockerFile}} . -t "$image_name:$IMAGE_TAG" --push