-
Notifications
You must be signed in to change notification settings - Fork 22
107 lines (105 loc) · 3.42 KB
/
build.yaml
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Image Build
on:
push:
branches:
- '**'
tags:
- 'v*.*.*'
pull_request:
branches:
- 'master'
jobs:
Build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Docker meta for KubeSphere
id: meta
if: github.repository_owner == 'kubesphere'
uses: docker/metadata-action@v3
with:
images: |
kubespheredev/s2irun
ghcr.io/${{ github.repository_owner }}/s2irun
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{raw}}
type=sha
- name: Docker meta for Contributors
id: metaContributors
if: github.repository_owner != 'kubesphere'
uses: docker/metadata-action@v3
with:
images: |
ghcr.io/${{ github.repository_owner }}/s2irun
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{raw}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_SECRETS }}
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Build env
id: build_env
run: |
if [ "${{ github.event_name }}" == "pull_request" ]
then
echo "::set-output name=platforms::linux/amd64"
echo "::set-output name=push::false"
echo "::set-output name=load::true"
else
echo "::set-output name=platforms::linux/amd64,linux/arm64"
echo "::set-output name=push::true"
echo "::set-output name=load::false"
fi
echo "::set-output name=short_sha::${GITHUB_SHA::7}"
- name: Build and push Docker images
uses: docker/[email protected]
if: github.repository_owner == 'kubesphere'
with:
context: .
file: Dockerfile
tags: ${{ steps.meta.outputs.tags }}
push: ${{ steps.build_env.outputs.push }}
load: ${{ steps.build_env.outputs.load }}
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ steps.build_env.outputs.platforms }}
- name: Build and push Docker images for Contributors
uses: docker/[email protected]
if: github.repository_owner != 'kubesphere'
with:
context: .
file: Dockerfile
tags: ${{ steps.metaContributors.outputs.tags }}
push: ${{ steps.build_env.outputs.push }}
load: ${{ steps.build_env.outputs.load }}
labels: ${{ steps.metaContributors.outputs.labels }}
platforms: ${{ steps.build_env.outputs.platforms }}
- name: Run Trivy vulnerability scanner
uses: aquasecurity/[email protected]
if: github.event_name == 'pull_request'
with:
image-ref: 'ghcr.io/${{ github.repository_owner }}/s2irun:sha-${{ steps.build_env.outputs.short_sha }}'
format: 'table'
exit-code: '1'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'