forked from bmdepesa/jenkins-casc
-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (61 loc) · 1.49 KB
/
build-and-push.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
# TODO: Update to pinned versions
name: Build and Push
on:
push:
paths:
- 'jenkins/**'
- 'dind-agent/**'
branches:
- "master"
tags:
- "v*"
pull_request:
branches:
- "master"
paths:
- 'jenkins/**'
- 'dind-agent/**'
env:
IMAGE_OWNER: ${{ github.repository_owner }}
jobs:
build-and-push:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- path: ./jenkins
image: caliskanugur/jenkins-server
- path: ./dind-agent
image: caliskanugur/jenkins-agent
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ matrix.image }}
tags: |
type=raw,value=head
-
name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ env.IMAGE_OWNER }}
password: ${{ secrets.DOCKER_TOKEN }}
-
name: Build Image
uses: docker/build-push-action@v6
with:
context: ${{ matrix.path }}
push: ${{ github.event_name != 'pull_request' }}
load: ${{ github.event_name == 'pull_request' }}
file: ${{ matrix.path }}/Dockerfile
tags: |
${{ steps.meta.outputs.tags }}