-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (90 loc) · 2.78 KB
/
Copy path_docker-build-push.yml
File metadata and controls
98 lines (90 loc) · 2.78 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
name: _Docker Build & Push (reusable)
on:
workflow_call:
inputs:
image-name:
description: Image name without registry prefix (e.g. platform-api)
required: true
type: string
dockerfile:
description: Path to Dockerfile relative to context (e.g. apps/api/Dockerfile)
required: true
type: string
context:
description: Docker build context relative to repo root (e.g. platform)
required: false
type: string
default: "."
acr-login-server:
description: ACR login server (e.g. deploycloudstagingacr.azurecr.io)
required: true
type: string
extra-tags:
description: Newline-separated extra image tags (e.g. stable)
required: false
type: string
default: ""
build-args:
description: Newline-separated Docker build arguments
required: false
type: string
default: ""
outputs:
image-tag:
description: The sha-{8char} image tag that was pushed
value: ${{ jobs.build-push.outputs.image-tag }}
secrets:
AZURE_CLIENT_ID:
required: true
AZURE_TENANT_ID:
required: true
AZURE_SUBSCRIPTION_ID:
required: true
jobs:
build-push:
name: Build & Push ${{ inputs.image-name }}
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
id-token: write
contents: read
outputs:
image-tag: ${{ steps.meta.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Azure Login
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
use-oidc: true
- name: ACR Login
uses: azure/acr-login@v1
with:
login-server: ${{ inputs.acr-login-server }}
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ inputs.acr-login-server }}/${{ inputs.image-name }}
tags: |
type=sha,prefix=sha-,format=short
type=raw,value=latest
${{ inputs.extra-tags }}
- name: Build and Push
uses: docker/build-push-action@v6
with:
context: ${{ inputs.context }}
file: ${{ inputs.context }}/${{ inputs.dockerfile }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: ${{ inputs.build-args }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64
provenance: false