-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (95 loc) · 2.59 KB
/
release.yml
File metadata and controls
110 lines (95 loc) · 2.59 KB
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
108
109
110
name: Release
concurrency:
group: release-${{ github.repository }}
on:
pull_request:
branches:
- main
push:
tags:
- 'v*'
env:
FILE_PATH: "Containerfile"
IMAGE_NAME: ${{ github.repository }}
REGISTRY: ghcr.io
jobs:
lint-scan:
name: Lint/scan image
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v6
with:
fetch-depth: 1
path: .
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Build/load image
uses: docker/build-push-action@v6
with:
context: .
file: "${{ env.FILE_PATH }}"
load: true
push: false
tags: app-image:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Lint with Dockle
uses: goodwithtech/dockle-action@main
with:
image: app-image:${{ github.sha }}
format: 'list'
exit-code: '0'
exit-level: 'warn'
- name: Scan with Trivy
continue-on-error: true
uses: aquasecurity/trivy-action@master
with:
image-ref: app-image:${{ github.sha }}
format: 'table'
exit-code: '0'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
timeout: "10m"
release:
name: Release
runs-on: ubuntu-latest
needs:
- lint-scan
if: ${{ startsWith(github.event.ref, 'refs/tags/v') }}
permissions:
contents: read
packages: write
steps:
- name: Check out repo
uses: actions/checkout@v6
with:
fetch-depth: 1
path: .
- name: Log in to GitHub CR
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: metadata
name: Gather image metadata
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Release image
uses: docker/build-push-action@v6
with:
context: .
file: "${{ env.FILE_PATH }}"
push: true
labels: ${{ steps.metadata.outputs.labels }}
tags: ${{ steps.metadata.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max