-
Notifications
You must be signed in to change notification settings - Fork 1
69 lines (59 loc) · 1.81 KB
/
Copy pathdocker-build-push.yml
File metadata and controls
69 lines (59 loc) · 1.81 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
name: 'Docker image build and push to container registry'
on:
workflow_call:
inputs:
container-registry:
required: true
type: string
image-name:
required: true
type: string
secrets:
registry-username:
required: true
registry-access-token:
required: true
defaults:
run:
shell: bash
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
security-events: write
steps:
- name: Checkout repository 🛎️
uses: actions/checkout@v7
- name: Log into registry ${{ inputs.container-registry }} 🔐
uses: docker/login-action@v4.6.0
with:
registry: ${{ inputs.container-registry }}
username: ${{ secrets.registry-username }}
password: ${{ secrets.registry-access-token }}
- name: Extract Docker metadata 🏷️
id: meta
uses: docker/metadata-action@v6.2.0
with:
images: ${{ inputs.container-registry }}/${{ inputs.image-name }}
- name: Build and Push Docker image 🏗️
uses: docker/build-push-action@v7.3.0
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Scan image for vulnerabilities 📡
uses: anchore/scan-action@v7.4.2
id: scan
with:
image: ${{ inputs.container-registry }}/${{ inputs.image-name }}:latest
fail-build: false
only-fixed: true
- name: Inspect SARIF report 🗄️
run: cat ${{ steps.scan.outputs.sarif }}
- name: Upload scan SARIF report 🚀
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: ${{ steps.scan.outputs.sarif }}