-
Notifications
You must be signed in to change notification settings - Fork 5
138 lines (128 loc) · 4.03 KB
/
container.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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# SPDX-License-Identifier: MIT
# (c) Copyright 2023 Advanced Micro Devices, Inc.
name: "Container Image"
on:
workflow_dispatch:
inputs:
registry-prefix:
description: Registry host and org
type: string
# push:
# branches: [ master ]
# pull_request:
# branches: [ master ]
env:
registry-prefix: ${{ inputs.registry-prefix || format('ghcr.io/{0}', github.repository_owner) }}
permissions:
contents: read
packages: write
jobs:
container-build:
name: Container Build
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
app: [Operator, Device Plugin]
include:
- app: Operator
image-repo: onload-operator
- app: Device Plugin
image-repo: onload-device-plugin
dockerfile_prefix: deviceplugin.
outputs:
digests: ${{ steps.build.outputs.digest }}
env:
DOCKER_CONFIG: .docker
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Login to registry
uses: docker/#-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Metadata - Docker tagging
id: meta
uses: docker/metadata-action@v5
with:
flavor: |
latest=false
images: |
${{ env.registry-prefix }}/${{ matrix.image-repo }}
tags: |
type=ref,event=branch,suffix=-dev
type=ref,event=tag,suffix=-dev
type=ref,event=pr,prefix=pr-
type=semver,pattern={{version}},suffix=-dev
type=sha,prefix=git-,format=short
- name: Metadata - summarise
env:
TITLE: ${{ matrix.image-repo }}
run: |
{
echo "# $TITLE"
echo '## Metadata output'
echo '### Tags'
echo '```'
echo "$DOCKER_METADATA_OUTPUT_TAGS"
echo '```'
echo '### Labels'
echo '```'
echo "$DOCKER_METADATA_OUTPUT_LABELS"
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
- name: Build
id: build
uses: docker/build-push-action@v5
with:
file: ${{ matrix.dockerfile_prefix }}Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true
- name: Build - summarise
env:
IMAGE_REPO: ${{ env.registry-prefix }}/${{ matrix.image-repo }}
DIGEST: ${{ steps.build.outputs.digest }}
IMAGEID: ${{ steps.build.outputs.imageid }}
run: |
{
echo '## Build output'
echo "[\`$IMAGE_REPO\`](https://$IMAGE_REPO)@\`$DIGEST\`"
echo "Image ID (Config): \`$IMAGEID\`"
} >> "$GITHUB_STEP_SUMMARY"
- name: Preflight
id: preflight
uses: docker://quay.io/opdev/preflight:1.7.0
with:
args: check container ${{ env.registry-prefix }}/${{ matrix.image-repo }}@${{ steps.build.outputs.digest }} # --submit
continue-on-error: true
env:
PFLT_DOCKERCONFIG: ${{ github.workspace }}/.docker/config.json
PFLT_PYXIS_API_TOKEN:
PFLT_CERTIFICATION_PROJECT_ID:
PFLT_ARTIFACTS: ${{ github.workspace }}/preflight-artifacts
- name: Preflight - summarise
env:
DOCKERFILE: ${{ matrix.dockerfile_prefix }}Dockerfile
run: |
{
echo '## Preflight output'
echo "For \`$DOCKERFILE\`"
echo '### Results'
echo '```json'
echo """$(cat preflight-artifacts/*/results.json || echo Missing)"""
echo '```'
echo '### RPM Manifest'
echo '```json'
echo """$(cat preflight-artifacts/*/rpm-manifest.json || echo Missing)"""
echo '```'
echo '### Cert Image'
echo '```json'
echo """$(cat preflight-artifacts/*/cert-image.json || echo Missing)"""
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
if [ "$(jq .passed preflight-artifacts/*/results.json)" == "false" ]; then
echo "::error file=$DOCKERFILE::Preflight failed"
fi