forked from mosaicml/composer
-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (86 loc) · 2.43 KB
/
docker-configure-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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Docker Image Configure-Build-Push
on:
workflow_call:
inputs:
build-args:
required: false
type: string
context:
required: true
type: string
image-name:
required: true
type: string
image-uuid:
required: false
type: string
push:
required: true
type: boolean
staging:
required: true
type: boolean
staging-repo:
required: false
type: string
tags:
required: true
type: string
target:
required: false
type: string
secrets:
username:
required: true
password:
required: true
jobs:
configure-build-push:
runs-on: ubuntu-latest
steps:
- name: Maximize Build Space on Worker
uses: easimon/maximize-build-space@v4
with:
overprovision-lvm: true
remove-dotnet: true
remove-android: true
remove-haskell: true
- name: Checkout
uses: actions/checkout@v3
- name: Setup QEMU
uses: docker/setup-qemu-action@v2
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.username }}
password: ${{ secrets.password }}
- name: Calculate Docker Image Variables
run: |
set -euo pipefail
###################
# Calculate the tag
###################
if [ "${{ inputs.staging }}" = "true" ]; then
STAGING_REPO=${{ inputs.staging-repo }}
IMAGE_TAG=${STAGING_REPO}:${{ inputs.image-uuid }}
IMAGE_CACHE="${STAGING_REPO}:${{ inputs.image-name }}-buildcache"
else
IMAGE_TAG=${{ inputs.tags }}
IMAGE_CACHE="${IMAGE_TAG/,*/}-buildcache"
fi
echo "IMAGE_TAG=${IMAGE_TAG}" >> ${GITHUB_ENV}
echo "IMAGE_CACHE=${IMAGE_CACHE}" >> ${GITHUB_ENV}
- name: IMAGE_TAG = ${{ env.IMAGE_TAG }}
run: echo ${{ env.IMAGE_TAG }}
- name: Build and Push the Docker Image
uses: docker/build-push-action@v3
with:
context: ${{ inputs.context }}
tags: ${{ env.IMAGE_TAG }}
target: ${{ inputs.target }}
push: ${{ inputs.push }}
cache-from: type=registry,ref=${{ env.IMAGE_CACHE }}
cache-to: type=registry,ref=${{ env.IMAGE_CACHE }},mode=max
build-args: ${{ inputs.build-args }}