-
Notifications
You must be signed in to change notification settings - Fork 122
97 lines (92 loc) · 3.03 KB
/
release_docker_container.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
# This workflow will build a docker image and push it to Docker Hub
name: release_docker
on:
workflow_call:
inputs:
dockerfile:
required: true
type: string
description: "Path to the Dockerfile to build"
image:
required: true
type: string
description: "Name of the image to build"
appendix_tag:
required: false
type: string
description: "Appendix tag to add to the image, e.g. `-cpu`"
context:
required: false
type: string
description: "Path to the build context"
default: "./libs/infinity_emb"
platforms:
required: false
type: string
description: "Platforms to build for"
default: "linux/amd64,linux/arm64"
env:
TEST_TAG: ${{ inputs.image }}:test
LATEST_TAG: ${{ inputs.image }}:latest
APPENDIX_TAG: ${{ inputs.appendix_tag || '' }}
jobs:
docker:
runs-on: ubuntu-latest
environment:
name: publish
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Free Disk Space
uses: "./.github/actions/disk_cleanup"
if: runner.os == 'Linux'
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: false
swap-storage: false
- name: Get git tag
uses: actions-ecosystem/action-get-latest-tag@v1
id: get-latest-tag
- name: Set docker tag
env:
VERSION: ${{ steps.get-latest-tag.outputs.tag }}
run: |
echo "VERSION_TAG=${{ inputs.image }}:${VERSION#v}" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Uncomment the following steps if you want to build and test the image locally
# - name: Build for Test
# uses: docker/build-push-action@v5
# with:
# context: ${{ inputs.context }}
# file: ${{ inputs.dockerfile }}
# load: true
# tags: ${{ env.TEST_TAG }}
#
# - name: Test
# # show that at least --help command is running
# run: |
# docker run --rm ${{ env.TEST_TAG }} --help
- name: Build and Push to Docker Hub
uses: docker/build-push-action@v5
with:
context: ${{ inputs.context }}
file: ${{ inputs.dockerfile }}
# We can only build for the intersection of platforms supported by
# QEMU and base python image, for now build only for
# linux/amd64 and linux/arm64
# cache-from: type=registry,ref=${{ env.LATEST_TAG }}
platforms: ${{ inputs.platforms }}
tags: ${{ env.LATEST_TAG }}${{ env.APPENDIX_TAG }},${{ env.VERSION_TAG }}${{ env.APPENDIX_TAG }}
push: true