-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (49 loc) · 1.3 KB
/
build-images.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
name: Build Images
on:
workflow_call:
inputs:
images:
required: true
type: string
push:
required: true
type: boolean
secrets:
DOCKERHUB_USERNAME:
required: true
DOCKERHUB_TOKEN:
required: true
jobs:
build:
name: Build
if: inputs.images != '[]'
runs-on: ubuntu-latest
strategy:
matrix:
include: ${{ fromJSON(inputs.images) }}
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build image
uses: docker/build-push-action@v4
with:
context: '{{defaultContext}}:${{ matrix.context }}'
file: '${{ matrix.file }}'
push: ${{ inputs.push }}
tags: paescuj/${{ matrix.name }}:latest
cache-from: type=gha,scope=${{ matrix.name }}
cache-to: type=gha,mode=max,scope=${{ matrix.name }}
result:
name: Result
if: inputs.images != '[]' && always()
runs-on: ubuntu-latest
needs: build
steps:
- name: Mark result as failed
if: needs.build.result != 'success'
run: exit 1