-
Notifications
You must be signed in to change notification settings - Fork 24
76 lines (64 loc) · 2.13 KB
/
build-scan-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
65
66
67
68
69
70
71
72
73
74
75
76
name: Build and Push Docker Image
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Lint Dockerfile with Hadolint
uses: hadolint/[email protected]
with:
dockerfile: Dockerfile
- name: Lint Shell Script with ShellCheck
uses: ludeeus/action-shellcheck@master
- name: Lint Kubernetes resources with KubeLinter
id: kube-lint-scan
uses: stackrox/kube-linter-action@v1
with:
directory: k8s
config: .kube-linter/config.yaml
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
tags: |
${{ secrets.DOCKER_USERNAME }}/docker-bitlbee:${{ github.sha }}
ghcr.io/${{ github.repository_owner }}/docker-bitlbee:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Scan Docker image for vulnerabilities with Trivy
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ secrets.DOCKER_USERNAME }}/docker-bitlbee:${{ github.sha }}
format: 'table'
ignore-unfixed: true
vuln-type: 'os,library'
exit-code: '1'
severity: 'CRITICAL,HIGH'
- name: Upload Trivy Report
uses: actions/upload-artifact@v3
with:
name: trivy-scan-results
path: trivy-results.json
- name: Push Docker image
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/docker-bitlbee:${{ github.sha }}
docker push ghcr.io/${{ github.repository_owner }}/docker-bitlbee:${{ github.sha }}