1
1
---
2
- name : litmus-ansible-ci
2
+ name : Build
3
3
on :
4
4
pull_request :
5
- branches :
6
- - master
7
- push :
8
- branches :
9
- - master
10
- tags-ignore :
11
- - ' **'
5
+ branches : [master]
6
+ types : [opened, synchronize, reopened]
12
7
13
8
env :
14
9
DOCKER_REPO : litmuschaos
15
10
DOCKER_IMAGE : ansible-runner
16
11
DOCKER_TAG : ci
17
12
18
- defaults :
19
- run :
20
- shell : bash
21
-
22
13
jobs :
23
-
24
- build :
14
+ pre-checks :
25
15
runs-on : ubuntu-latest
26
16
steps :
27
- - name : Checkout
28
- uses : actions/checkout@v2
17
+ - uses : actions/checkout@v2
18
+ with :
19
+ ref : ${{ github.event.pull_request.head.sha }}
29
20
30
- - name : Build Image
31
- env :
32
- SAVE_PATH : ${{ github.workspace }}
33
- run : |
34
- make build
35
- make save
36
- chmod +x ${{ github.workspace }}/image.tar
21
+ - name : checking dependencies are installed
22
+ run : make deps
37
23
38
- - name : Upload artifact
39
- uses : actions/upload-artifact@v2
24
+ - name : Running ansible syntax-checks
25
+ run : make syntax-checks
26
+
27
+ - name : Running ansible lint-checks
28
+ run : make lint-checks
29
+
30
+ gitleaks-scan :
31
+ runs-on : ubuntu-latest
32
+ steps :
33
+ - uses : actions/checkout@v3
40
34
with :
41
- name : myimage
42
- path : |
43
- ${{ github.workspace }}/image.tar
44
- ${{ github.workspace }}/tag.txt
35
+ fetch-depth : 0
36
+ - name : Run GitLeaks
37
+ run : |
38
+ wget https://github.com/gitleaks/gitleaks/releases/download/v8.18.2/gitleaks_8.18.2_linux_x64.tar.gz && \
39
+ tar -zxvf gitleaks_8.18.2_linux_x64.tar.gz && \
40
+ sudo mv gitleaks /usr/local/bin && gitleaks detect --source . -v
41
+
45
42
46
- image-checks :
43
+ build :
44
+ needs : pre-checks
47
45
runs-on : ubuntu-latest
48
- needs : build
49
46
steps :
50
- - name : Checkout
51
- uses : actions/checkout@v2
47
+ - uses : actions/checkout@v2
48
+ with :
49
+ ref : ${{ github.event.pull_request.head.sha }}
52
50
53
- - name : Download artifact
54
- uses : actions/download-artifact@v2
51
+ - name : Set up QEMU
52
+ uses : docker/setup-qemu-action@v1
55
53
with :
56
- name : myimage
57
- path : ${{ github.workspace }}
58
-
59
- - name : Load Docker image
60
- run : |
61
- docker load --input ${{ github.workspace }}/image.tar
54
+ platforms : all
62
55
63
- - name : checking dependencies are installed
64
- run : make deps
65
-
66
- - name : Running ansible syntax-checks
67
- run : make syntax-checks
56
+ - name : Set up Docker Buildx
57
+ id : buildx
58
+ uses : docker/setup-buildx-action@v1
59
+ with :
60
+ version : latest
68
61
69
- - name : Running ansible lint-checks
70
- run : make lint-checks
62
+ - name : Build and push
63
+ uses : docker/build-push-action@v2
64
+ with :
65
+ push : false
66
+ file : build/ansible-runner/Dockerfile
67
+ platforms : linux/amd64
68
+ tags : litmuschaos/ansible-runner:ci
71
69
70
+ trivy :
71
+ needs : pre-checks
72
+ runs-on : ubuntu-latest
73
+ steps :
72
74
- uses : actions/checkout@v2
73
75
with :
74
- ref : ${{ github.event.pull_request.head.sha }}
76
+ ref : ${{ github.event.pull_request.head.sha }}
77
+
78
+ - name : Build an image from Dockerfile
79
+ run : |
80
+ docker build -f build/ansible-runner/Dockerfile -t docker.io/litmuschaos/ansible-runner:${{ github.sha }} . --build-arg TARGETARCH=amd64
75
81
76
82
- name : Run Trivy vulnerability scanner
77
83
uses : aquasecurity/trivy-action@master
78
84
with :
79
- image-ref : ' litmuschaos/ansible-runner:ci '
85
+ image-ref : ' docker.io/ litmuschaos/ansible-runner:${{ github.sha }} '
80
86
format : ' table'
81
87
exit-code : ' 1'
82
88
ignore-unfixed : true
83
89
vuln-type : ' os,library'
84
- severity : ' CRITICAL,HIGH'
85
-
86
- push :
87
- runs-on : ubuntu-latest
88
- needs : [build,image-checks]
89
- if : github.event_name == 'push'
90
- steps :
91
- - name : Checkout
92
- uses : actions/checkout@v2
93
-
94
- - name : Download artifact
95
- uses : actions/download-artifact@v2
96
- with :
97
- name : myimage
98
- path : ${{ github.workspace }}
99
-
100
- - name : Load Docker image
101
- run : |
102
- docker load --input ${{ github.workspace }}/image.tar
103
-
104
- - name : Push Image
105
- env :
106
- DNAME : ${{ secrets.DNAME }}
107
- DPASS : ${{ secrets.DPASS }}
108
- run : |
109
- make push
90
+ severity : ' CRITICAL,HIGH'
0 commit comments