Build & Push Docker #10
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build & Push Docker | |
on: | |
workflow_dispatch: | |
inputs: | |
latest: | |
type: boolean | |
description: "Tag image also as 'latest'" | |
default: false | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Checkout | |
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: Optionally remove 'v' from tag | |
run: | | |
VERSION=$(echo "${{ github.ref_name }}" | sed -r 's/^v([0-9]+(\.[0-9]+)*)$/\1/') | |
echo "IMAGE_TAG=${{ secrets.DOCKERHUB_USERNAME }}/laikallm:$VERSION" >> $GITHUB_ENV | |
echo "Tag version: ${VERSION}" | |
- | |
if: inputs.latest == true | |
name: Append 'latest' tag to docker image | |
run: | | |
LOCAL_IMAGE_TAG="${IMAGE_TAG},${{ secrets.DOCKERHUB_USERNAME }}/laikallm:latest" | |
echo "IMAGE_TAG=$LOCAL_IMAGE_TAG" >> $GITHUB_ENV | |
echo "Image tags: ${LOCAL_IMAGE_TAG}" | |
- | |
name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
tags: ${{ env.IMAGE_TAG }} |