1
+ env :
2
+ CONTAINER_IMAGE_TAG : githubchangeloggenerator/github-changelog-generator:latest
3
+
1
4
name : Build and deploy latest image
2
5
3
6
on : [push, pull_request]
4
7
5
8
jobs :
6
- build :
9
+ lint :
7
10
name : Lint the codebase
8
11
runs-on : ubuntu-20.04
9
12
steps :
@@ -15,28 +18,46 @@ jobs:
15
18
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
16
19
LINTER_RULES_PATH : .
17
20
VALIDATE_ALL_CODEBASE : true
18
- push :
19
- if : ${{ github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) }}
20
- environment : Docker Hub
21
- name : Deploy latest image (Docker Hub)
22
- needs : build
21
+ build :
22
+ name : Build and test the container image
23
+ needs : lint
23
24
runs-on : ubuntu-20.04
24
25
steps :
25
26
26
27
- name : Setup Docker Buildx
27
28
uses : docker/setup-buildx-action@v1
28
29
- name : Set up QEMU
29
30
uses : docker/setup-qemu-action@v1
31
+ - name : Build the container image for x86_64 only
32
+ uses : docker/build-push-action@v2
33
+ with :
34
+ context : .
35
+ file : ./Dockerfile
36
+ platforms : linux/amd64
37
+ push : false
38
+ tags : ${{ env.CONTAINER_IMAGE_TAG }}
39
+ - name : Test the container image
40
+ shell : bash
41
+ run : docker run ${{ env.CONTAINER_IMAGE_TAG }}
42
+ deploy :
43
+ env :
44
+ PUSH_IMAGES : ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
45
+ environment : Docker Hub
46
+ if : ${{ env.PUSH_IMAGES }}
47
+ name : Deploy the container image
48
+ needs : build
49
+ runs-on : ubuntu-20.04
50
+ steps :
30
51
- name : Login to Docker Hub
31
52
uses : docker/login-action@v1
32
53
with :
33
54
username : ${{ secrets.DOCKERHUB_USERNAME }}
34
55
password : ${{ secrets.DOCKERHUB_TOKEN }}
35
- - name : Push to Docker Hub (latest)
56
+ - name : Build the contaiiner image for all the platforms and eventually push to Docker Hub (latest)
36
57
uses : docker/build-push-action@v2
37
58
with :
38
59
context : .
39
60
file : ./Dockerfile
40
61
platforms : linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
41
- push : true
42
- tags : githubchangeloggenerator/github-changelog-generator:latest
62
+ push : ${{ env.PUSH_IMAGES }}
63
+ tags : ${{ env.CONTAINER_IMAGE_TAG }}
0 commit comments