LibreTranslate/.github/workflows/publish-docker.yml
2023-11-16 15:43:47 -05:00

74 lines
2.3 KiB
YAML

name: Build and Publish Docker Image
on:
push:
branches:
- main
tags:
- v*
jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- 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 }}
- name: Get Variables
id: get-variables
run: |
echo ::set-output name=version::${GITHUB_REF#refs/tags/}
echo ::set-output name=gh-username-lower::$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')
- name: Build and push Image
uses: docker/build-push-action@v5
with:
file: ./docker/Dockerfile
platforms: linux/amd64,linux/arm64
tags: ${{ steps.get-variables.outputs.gh-username-lower }}/libretranslate:${{ env.TAG }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
env:
TAG: ${{ startsWith(github.ref, 'refs/tags/') && steps.get-variables.outputs.version || 'latest' }}
- name: Free Disk Space (Ubuntu)
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
# 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
docker-images: true
swap-storage: true
- name: Build and push Cuda Image
uses: docker/build-push-action@v5
with:
file: ./docker/cuda.Dockerfile
platforms: linux/amd64
tags: ${{ steps.get-variables.outputs.gh-username-lower }}/libretranslate:${{ env.TAG }}-cuda
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
env:
TAG: ${{ startsWith(github.ref, 'refs/tags/') && steps.get-variables.outputs.version || 'latest' }}