LibreTranslate/.github/workflows/publish-docker.yml
2022-03-30 12:29:33 +00:00

52 lines
1.4 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@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GHCR
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get Version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
- name: Build and push Image
uses: docker/build-push-action@v2
with:
platforms: linux/amd64
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/libretranslate:${{ env.TAG }},
ghcr.io/${{ github.repository_owner }}/libretranslate:${{ env.TAG }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
env:
TAG: ${{ startsWith(github.ref, 'refs/tags/') && steps.get_version.outputs.VERSION || 'latest' }}