forked from hexgrad/kokoro
-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (70 loc) · 2.29 KB
/
Copy pathdocker-build-tiny.yml
File metadata and controls
82 lines (70 loc) · 2.29 KB
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
name: Build and Push Docker Image (TINY)
on:
push:
branches:
- main
tags:
- "v*.*"
- "v*.*.*"
workflow_dispatch:
inputs:
image_tag:
description: "Optional Docker tag to publish, for example v0.2"
required: false
type: string
checkout_ref:
description: "Optional git ref to build. Defaults to image_tag when image_tag is set."
required: false
type: string
push_latest:
description: "Also publish tiny"
required: false
default: true
type: boolean
env:
IMAGE_NAME: hangrylabs/kokorotts
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.checkout_ref || inputs.image_tag || github.ref }}
- name: Free up disk space
run: |
echo "Initial disk usage:"
df -h
sudo rm -rf /usr/share/dotnet || true
sudo rm -rf /opt/ghc || true
sudo rm -rf /usr/local/lib/android || true
sudo rm -rf /opt/hostedtoolcache || true
docker system prune -af || true
echo "Disk usage after cleanup:"
df -h
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
run: echo "${{ secrets.DOCKER_TOKEN }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
- name: Extract version if tag
id: get_version
run: |
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
echo "VERSION=${GITHUB_REF##refs/tags/}" >> $GITHUB_ENV
elif [[ -n "${{ inputs.image_tag }}" ]]; then
echo "VERSION=${{ inputs.image_tag }}" >> $GITHUB_ENV
fi
- name: Build tiny Docker image
run: |
docker build --target tiny -t $IMAGE_NAME:tiny .
if [[ -n "$VERSION" ]]; then
docker tag $IMAGE_NAME:tiny $IMAGE_NAME:${VERSION}_tiny
fi
- name: Push tiny Docker image
run: |
if [[ "${{ github.event_name }}" != "workflow_dispatch" || "${{ inputs.push_latest }}" == "true" ]]; then
docker push $IMAGE_NAME:tiny
fi
if [[ -n "$VERSION" ]]; then
docker push $IMAGE_NAME:${VERSION}_tiny
fi