Skip to content

Commit 58838b3

Browse files
committed
use reusable workflows to test PRs without pushing to the registry
1 parent 4bbdd1c commit 58838b3

File tree

3 files changed

+66
-37
lines changed

3 files changed

+66
-37
lines changed
Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
name: Build Docker Image
22

33
on:
4-
push:
5-
branches:
6-
- "master"
4+
workflow_call:
5+
inputs:
6+
push_images:
7+
default: false
8+
type: boolean
9+
secrets:
10+
dockerhub_username:
11+
dockerhub_token:
712

813
jobs:
914
docker:
@@ -18,109 +23,110 @@ jobs:
1823
- name: Login to DockerHub
1924
uses: docker/login-action@v1
2025
with:
21-
username: ${{ secrets.DOCKERHUB_USERNAME }}
22-
password: ${{ secrets.DOCKERHUB_TOKEN }}
23-
- name: Build And Push 7.1-alpine
26+
username: ${{ secrets.dockerhub_username }}
27+
password: ${{ secrets.dockerhub_token }}
28+
if: github.ref_name == github.event.repository.default_branch
29+
- name: Build 7.1-alpine
2430
uses: docker/build-push-action@v2
2531
with:
2632
context: .
2733
file: ./images/7.1/Dockerfile-alpine
28-
push: true
34+
push: ${{ inputs.push_images }}
2935
tags: umutphp/php-docker-images-for-ci:7.1-alpine
30-
- name: Build And Push 7.2-alpine
36+
- name: Build 7.2-alpine
3137
uses: docker/build-push-action@v2
3238
with:
3339
context: .
3440
file: ./images/7.2/Dockerfile-alpine
35-
push: true
41+
push: ${{ inputs.push_images }}
3642
tags: umutphp/php-docker-images-for-ci:7.2-alpine
37-
- name: Build And Push 7.3-alpine
43+
- name: Build 7.3-alpine
3844
uses: docker/build-push-action@v2
3945
with:
4046
context: .
4147
file: ./images/7.3/Dockerfile-alpine
42-
push: true
48+
push: ${{ inputs.push_images }}
4349
tags: umutphp/php-docker-images-for-ci:7.3-alpine
44-
- name: Build And Push 7.4-alpine
50+
- name: Build 7.4-alpine
4551
uses: docker/build-push-action@v2
4652
with:
4753
context: .
4854
file: ./images/7.4/Dockerfile-alpine
49-
push: true
55+
push: ${{ inputs.push_images }}
5056
tags: umutphp/php-docker-images-for-ci:7.4-alpine
51-
- name: Build And Push 8.0-alpine
57+
- name: Build 8.0-alpine
5258
uses: docker/build-push-action@v2
5359
with:
5460
context: .
5561
file: ./images/8.0/Dockerfile-alpine
56-
push: true
62+
push: ${{ inputs.push_images }}
5763
tags: umutphp/php-docker-images-for-ci:8.0-alpine
58-
- name: Build And Push 8.1-alpine
64+
- name: Build 8.1-alpine
5965
uses: docker/build-push-action@v2
6066
with:
6167
context: .
6268
file: ./images/8.1/Dockerfile-alpine
63-
push: true
69+
push: ${{ inputs.push_images }}
6470
tags: umutphp/php-docker-images-for-ci:8.1-alpine
65-
- name: Build And Push 8.2-alpine
71+
- name: Build 8.2-alpine
6672
uses: docker/build-push-action@v2
6773
with:
6874
context: .
6975
file: ./images/8.2/Dockerfile-alpine
70-
push: true
76+
push: ${{ inputs.push_images }}
7177
tags: umutphp/php-docker-images-for-ci:8.2-alpine
72-
- name: Build And Push 8.3-alpine
78+
- name: Build 8.3-alpine
7379
uses: docker/build-push-action@v2
7480
with:
7581
context: .
7682
file: ./images/8.3/Dockerfile-alpine
77-
push: true
83+
push: ${{ inputs.push_images }}
7884
tags: umutphp/php-docker-images-for-ci:8.3-alpine,umutphp/php-docker-images-for-ci:latest-alpine
79-
- name: Build And Push 7.1
85+
- name: Build 7.1
8086
uses: docker/build-push-action@v2
8187
with:
8288
context: ./images/7.1/
83-
push: true
89+
push: ${{ inputs.push_images }}
8490
tags: umutphp/php-docker-images-for-ci:7.1
85-
- name: Build And Push 7.2
91+
- name: Build 7.2
8692
uses: docker/build-push-action@v2
8793
with:
8894
context: ./images/7.2/
89-
push: true
95+
push: ${{ inputs.push_images }}
9096
tags: umutphp/php-docker-images-for-ci:7.2
91-
- name: Build And Push 7.3
97+
- name: Build 7.3
9298
uses: docker/build-push-action@v2
9399
with:
94100
context: ./images/7.3/
95-
push: true
101+
push: ${{ inputs.push_images }}
96102
tags: umutphp/php-docker-images-for-ci:7.3
97-
- name: Build And Push 7.4
103+
- name: Build 7.4
98104
uses: docker/build-push-action@v2
99105
with:
100106
context: ./images/7.4/
101-
push: true
107+
push: ${{ inputs.push_images }}
102108
tags: umutphp/php-docker-images-for-ci:7.4
103-
- name: Build And Push 8.0
109+
- name: Build 8.0
104110
uses: docker/build-push-action@v2
105111
with:
106112
context: ./images/8.0/
107-
push: true
113+
push: ${{ inputs.push_images }}
108114
tags: umutphp/php-docker-images-for-ci:8.0
109-
- name: Build And Push 8.1
115+
- name: Build 8.1
110116
uses: docker/build-push-action@v2
111117
with:
112118
context: ./images/8.1/
113-
push: true
119+
push: ${{ inputs.push_images }}
114120
tags: umutphp/php-docker-images-for-ci:8.1
115-
- name: Build And Push 8.2
121+
- name: Build 8.2
116122
uses: docker/build-push-action@v2
117123
with:
118124
context: ./images/8.2/
119-
push: true
125+
push: ${{ inputs.push_images }}
120126
tags: umutphp/php-docker-images-for-ci:8.2
121-
- name: Build And Push 8.3
127+
- name: Build 8.3
122128
uses: docker/build-push-action@v2
123129
with:
124130
context: ./images/8.3/
125-
push: true
131+
push: ${{ inputs.push_images }}
126132
tags: umutphp/php-docker-images-for-ci:8.3,umutphp/php-docker-images-for-ci:latest

.github/workflows/release.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Build & Push Docker Images
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
call-reusable-workflow:
10+
uses: ./.github/workflows/build-docker-image.yml
11+
with:
12+
push_images: true
13+
secrets:
14+
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
15+
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}

.github/workflows/test.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: Build Docker Images
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
call-reusable-workflow:
8+
uses: ./.github/workflows/build-docker-image.yml

0 commit comments

Comments
 (0)