forked from mosaicml/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (45 loc) · 1.42 KB
/
docker.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
name: Docker
on:
push:
branches:
- main
workflow_dispatch: {}
jobs:
docker-build:
runs-on: ubuntu-latest
if: github.repository_owner == 'mosaicml'
strategy:
matrix:
example:
- bert
- llm
steps:
- 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.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Calculate Docker Image Variables
run: |
set -euxo pipefail
###################
# Calculate the tag
###################
GIT_SHA=$(echo ${{ github.sha }} | cut -c1-7)
echo "IMAGE_TAG=${GIT_SHA}" >> ${GITHUB_ENV}
- name: Build and Push the Docker Image
uses: docker/build-push-action@v3
with:
context: .
tags: mosaicml/examples:${{ matrix.example }}-latest,
mosaicml/examples:${{ matrix.example }}-${{ env.IMAGE_TAG }}
push: ${{ contains(github.ref, 'refs/heads/main') }}
cache-from: type=registry,ref=mosaicml/examples:${{ matrix.example }}-buildcache
cache-to: type=registry,ref=mosaicml/examples:${{ matrix.example }}-buildcache,mode=max
build-args: EXAMPLE=${{ matrix.example }}