-
Notifications
You must be signed in to change notification settings - Fork 3
74 lines (64 loc) · 1.86 KB
/
docker.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
name: BuildPublishImage
on:
workflow_call:
inputs:
build_context:
description: 'build_context'
required: false
type: string
image_tag:
description: 'Image tag'
required: false
type: string
permissions:
id-token: write
contents: read
packages: write
env:
ACR_NAME: "monorepopwin.azurecr.io"
jobs:
BuildDocker:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 'Az CLI login'
uses: azure/login@v1
with:
client-id: ${{ vars.AZURE_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
allow-no-subscriptions: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.ACR_NAME }}/${{ inputs.build_context }}
tags: |
type=edge,branch=main
type=ref,event=tag
type=ref,event=pr
type=raw, ${{ inputs.image_tag}}
- name: Log into azurecr registry
run: |
TOKEN=$(az acr login --name ${{ env.ACR_NAME }} --expose-token --output tsv --query accessToken)
echo "::add-mask::${TOKEN}"
docker login ${{ env.ACR_NAME }} --username 00000000-0000-0000-0000-000000000000 --password-stdin <<< $TOKEN
shell: bash
- name: Build, push if not PR
uses: docker/build-push-action@v5
with:
context: model/${{ inputs.build_context }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
- name: Azure Logout
if: always()
run: |
az logout
az cache purge
az account clear
shell: bash