forked from GEWIS/gewisweb
-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (44 loc) · 2.19 KB
/
docker-build.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
name: Docker Image CI
# Only run this action when pushing to main (development release) or on tagged versions (latest release).
on:
push:
branches:
- main
tags:
- 'v*.*.*'
# Cancel running jobs that have become stale through updates to the ref (e.g., pushes to a pull request).
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
IS_RELEASE: ${{ format('{0}', startsWith(github.ref, 'refs/tags/')) }}
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
image: ['web', 'glide', 'matomo', 'nginx']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get short commit SHA
run: echo "SHORT_COMMIT_SHA=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Registry
uses: docker/login-action@v3
with:
registry: ${{ vars.ABC_DOCKER_REGISTRY }}
username: ${{ secrets.SVC_GH_ABCWEB_USERNAME }}
password: ${{ secrets.SVC_GH_ABCWEB_PWD }}
- name: Build and push image
uses: docker/build-push-action@v6
with:
build-args: GIT_COMMIT=${{ env.SHORT_COMMIT_SHA }}
cache-from: type=gha
cache-to: type=gha,mode=max
context: ${{ matrix.image == 'web' && '.' || format('./docker/{0}', matrix.image) }}
file: ${{ matrix.image == 'web' && (env.IS_RELEASE == 'true' && './docker/web/production/Dockerfile' || './docker/web/development/Dockerfile') || format('./docker/{0}/Dockerfile', matrix.image) }}
platforms: linux/amd64
push: true
tags: ${{ format('{0}:{1}', format('{0}/web/gewisweb/{1}', vars.ABC_DOCKER_REGISTRY, matrix.image), env.IS_RELEASE == 'true' && format('{0},{1}:latest', github.ref_name, format('{0}/web/gewisweb/{1}', vars.ABC_DOCKER_REGISTRY, matrix.image)) || 'development') }}