-
Notifications
You must be signed in to change notification settings - Fork 4
86 lines (78 loc) · 2.83 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
# SPDX-License-Identifier: BSD-3-Clause
# (c) Copyright 2023 Advanced Micro Devices, Inc.
name: "Container Image"
on:
workflow_dispatch:
inputs:
registry-prefix:
description: Registry host and org
type: string
sfptpd-version:
description: sfptpd version
type: string
ubi-image:
description: UBI_IMAGE
type: string
push:
branches: [ master, v3_7 ]
tags: [ v*, sfptpd-* ]
permissions:
contents: read
packages: write
jobs:
container-build:
if: vars.PUBLISHING_REPO
name: Container Build
runs-on: ubuntu-latest
timeout-minutes: 20
env:
REGISTRY_PREFIX: ${{ inputs.registry-prefix || '' }}
UBI_IMAGE: ${{ inputs.ubi-image || 'registry.access.redhat.com/ubi9-minimal:9.2' }}
SFPTPD_VERSION: ${{ inputs.sfptpd-version || '' }}
IMAGE_TAG_SUFFIX: ${{ vars.RELEASE == '' && '-dev' || '' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Metadata - env
run: |
repo="${GITHUB_REPOSITORY_OWNER@L}"
echo "REGISTRY_PREFIX=${REGISTRY_PREFIX:-ghcr.io/$repo}" | tee -a "$GITHUB_ENV"
versioning_output=$(./scripts/sfptpd_versioning derive)
echo "SFPTPD_VERSION=${SFPTPD_VERSION:-$versioning_output}" | tee -a "$GITHUB_ENV"
- name: Metadata - Docker tagging
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY_PREFIX }}/sfptpd
tags: |
type=semver,pattern={{version}},suffix=${{ env.IMAGE_TAG_SUFFIX }}
type=match,pattern=sfptpd-([\d\.]+),group=1,suffix=${{ env.IMAGE_TAG_SUFFIX }}
type=ref,event=pr,prefix=pr-
type=raw,value=${{ env.SFPTPD_VERSION }},suffix=${{ env.IMAGE_TAG_SUFFIX }}
type=ref,event=branch,suffix=${{ env.IMAGE_TAG_SUFFIX }}
type=sha,prefix=git-,format=short
type=raw,value=latest,enable={{is_default_branch}},suffix=${{ env.IMAGE_TAG_SUFFIX }}
type=raw,value=stable,enable=${{ github.ref == vars.STABLE_TAG_REF || false }},suffix=${{ env.IMAGE_TAG_SUFFIX }}
labels: |
org.opencontainers.image.version=${{ env.SFPTPD_VERSION }}
org.opencontainers.image.licenses=BSD-3-Clause AND BSD-2-Clause AND NTP AND ISC
- if: ${{ contains(env.REGISTRY_PREFIX, 'ghcr.io') }}
name: Login to registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build
id: build
uses: docker/build-push-action@v5
with:
context: .
file: Containerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true
build-args: |
SFPTPD_VERSION=${{ env.SFPTPD_VERSION }}
UBI_IMAGE=${{ env.UBI_IMAGE }}