-
Notifications
You must be signed in to change notification settings - Fork 442
96 lines (93 loc) · 2.94 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: publish-docker
on:
push:
paths-ignore:
- "!.github/workflows/docker.yml"
- ".github/**"
- "docs/**"
- "resources/**"
- "benchmark/**"
- "tests/**"
- "**/*.md"
- "autotest/**"
- "builder/**"
- "k8s/**"
branches:
- main
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
repo_ref:
required: false
description: 'Set branch or tag or commit id. Default is ""'
type: string
default: 'main'
image_tag:
required: true
description: 'Set docker image tag. Default is "latest"'
type: string
default: latest
jobs:
publish_docker_image:
runs-on: ubuntu-latest
environment: 'prod'
strategy:
matrix:
cuda_version: [cu12, cu11]
env:
CUDA_VERSION: ${{ matrix.cuda_version }}
TAG_PREFIX: "openmmlab/lmdeploy"
TAG: "openmmlab/lmdeploy:latest-${{matrix.cuda_version}}"
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{github.event.inputs.repo_ref}}
- name: Free disk space
uses: jlumbroso/free-disk-space@main
with:
# This might remove tools that are actually needed, if set to "true" but frees about 6 GB
tool-cache: false
docker-images: false
# All of these default to true, but feel free to set to "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
swap-storage: false
- name: Get docker info
run: |
docker info
# remove http extraheader
git config --local --unset "http.https://github.com/.extraheader"
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Update docker TAG from workflow input
if: github.event_name == 'workflow_dispatch'
run: |
export TAG=$TAG_PREFIX:${{github.event.inputs.image_tag}}-${CUDA_VERSION}
echo $TAG
echo "TAG=${TAG}" >> $GITHUB_ENV
- name: Build and push Docker image
run: |
echo $TAG
docker build . -f docker/Dockerfile -t ${TAG} --build-arg CUDA_VERSION=${CUDA_VERSION}
docker push $TAG
- name: Push docker image latest-cu12 as latest
if: endsWith(env.TAG, 'latest-cu12') == true
run: |
export latest_TAG=${TAG_PREFIX}:latest
echo $latest_TAG
docker tag $TAG $latest_TAG
docker push $latest_TAG
- name: Push docker image with released tag
if: startsWith(github.ref, 'refs/tags/') == true
run: |
export RELEASE_TAG=${TAG_PREFIX}:${{github.ref_name}}-${CUDA_VERSION}
echo $RELEASE_TAG
docker tag $TAG $RELEASE_TAG
docker push $RELEASE_TAG