-
Notifications
You must be signed in to change notification settings - Fork 196
116 lines (103 loc) · 3.5 KB
/
call-release-image.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Call Release Image
env:
REGISTRY: docker.io
IMAGE_REPO: ${{ secrets.IMAGE_REPO || 'projecthami/hami' }}
IMAGE_ROOT_PATH: docker
BUILD_PLATFORM: linux/arm64,linux/amd64
REGISTER_USER: ${{ github.actor }}
REGISTER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
on:
workflow_call:
inputs:
ref:
required: true
type: string
suffix:
required: false
type: string
tagoverride:
required: false
type: string
permissions: write-all
jobs:
docker-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Free disk space
# https://github.com/actions/virtual-environments/issues/709
run: |
echo "=========original CI disk space"
df -h
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
echo "=========after clean up, the left CI disk space"
df -h
- name: Getting Image Ref
id: ref
run: |
if ${{ inputs.ref != '' }} ; then
echo "call by workflow_call"
image_ref=${{ inputs.ref }}
image_suffix=${{ inputs.suffix }}
elif ${{ github.event_name == 'workflow_dispatch' }} ; then
echo "call by workflow_dispatch"
image_ref=${{ github.event.inputs.ref }}
image_suffix=${{ github.event.inputs.suffix }}
else
echo "unexpected event: ${{ github.event_name }}"
exit 1
fi
echo "ref=${image_ref}" >> $GITHUB_ENV
[ -n "${image_suffix}" ] && echo "suffix=-${image_suffix}" >> $GITHUB_ENV
if ${{ inputs.tagoverride != '' }} ; then
echo "imagetag=${{ inputs.tagoverride }}" >> $GITHUB_ENV
else
# it is invalid if the ref is branch name "xx/xx/xx"
echo "imagetag=${image_ref##*/}" >> $GITHUB_ENV
fi
exit 0
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
ref: ${{ steps.ref.outputs.ref }}
- name: Checkout submodule
uses: Mushus/[email protected]
with:
basePath: # optional, default is .
submodulePath: libvgpu
- name: Lint Dockerfile
run: |
make lint_dockerfile
- name: Docker Login
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_TOKEN }}
password: ${{ secrets.DOCKERHUB_PASSWD }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: image=moby/buildkit:master
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}
- name: Build & Pushing hami image
uses: docker/[email protected]
with:
context: .
file: ${{ env.IMAGE_ROOT_PATH }}/Dockerfile
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ env.BUILD_PLATFORM }}
build-args: |
VERSION=${{ env.ref }}
GOLANG_IMAGE=golang:1.22.5-bullseye
NVIDIA_IMAGE=nvidia/cuda:12.2.0-devel-ubuntu20.04
DEST_DIR=/usr/local
tags: ${{ steps.meta.outputs.tags }}
push: true
github-token: ${{ env.REGISTER_PASSWORD }}