-
Notifications
You must be signed in to change notification settings - Fork 3
75 lines (66 loc) · 2.23 KB
/
reusable-docker-build-push.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
# SPDX-FileCopyrightText: Copyright (c) 2025 Cisco and/or its affiliates.
# SPDX-License-Identifier: Apache-2.0
---
name: Build and Push
on:
workflow_call:
inputs:
bake-target:
required: true
type: string
description: "Bake target"
bake-file:
required: false
type: string
description: "Bake file"
default: "docker-bake.hcl"
image-name:
required: true
type: string
description: "Image repo to use."
image-tag:
required: true
type: string
description: "Image tag to use."
secrets:
github-token:
description: "github token"
required: false
jobs:
build-and-push:
name: Build and Push
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
fetch-depth: 0
- name: Login to GitHub Container Registry
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.github-token}}
- name: Setup QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
- name: Docker metadata
id: metadata
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: |
ghcr.io/agntcy/acp/${{ inputs.image-name }}
tags: |
type=raw,value=${{ inputs.image-tag }}
type=raw,value=latest,enable=${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
- name: Build and push
uses: docker/bake-action@4ba453fbc2db7735392b93edf935aaf9b1e8f747 # v6.5.0
with:
files: |
${{ inputs.bake-file }}
${{ steps.metadata.outputs.bake-file }}
targets: ${{ inputs.bake-target }}
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
provenance: false