Merge pull request #43 from hv0905/custom-comment #107
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: Check & deploy to DockerHub | |
on: | |
push: | |
branches: | |
- 'master' | |
tags: | |
- '*' | |
workflow_dispatch: | |
jobs: | |
perform-check: | |
uses: ./.github/workflows/test_lint.yml | |
secrets: inherit | |
docker: | |
runs-on: ubuntu-latest | |
environment: DockerHub | |
needs: | |
- perform-check | |
strategy: | |
matrix: | |
configurations: | |
- dockerfile: "Dockerfile" | |
suffixes: | | |
"" | |
"-cuda" | |
"-cuda12.1" | |
args: | | |
CUDA_VERSION=12.1 | |
- dockerfile: "Dockerfile" | |
suffixes: '"-cuda11.8"' | |
args: | | |
CUDA_VERSION=11.8 | |
- dockerfile: "cpu-only.Dockerfile" | |
suffixes: '"-cpu"' | |
args: "" | |
steps: | |
- 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: Docker Meta | |
id: docker-meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: edgeneko/neko-image-gallery | |
tags: | | |
type=edge,branch=master | |
type=semver,pattern=v{{version}} | |
type=semver,pattern=v{{major}}.{{minor}} | |
- name: Build combined tags | |
id: combine-tags | |
run: | | |
SUFFIXES=(${{ matrix.configurations.suffixes }}) | |
echo 'tags<<EOF' >> $GITHUB_OUTPUT | |
for SUFFIX in "${SUFFIXES[@]}"; do | |
echo '${{ steps.docker-meta.outputs.tags }}' | sed 's/$/'"$SUFFIX"'/' >> $GITHUB_OUTPUT | |
done | |
echo EOF >> $GITHUB_OUTPUT | |
printf 'cache_tag=%s' "$(echo '${{ steps.docker-meta.outputs.tags }}' | tail -1 | sed 's/$/'"${SUFFIXES[0]}"'/')" >> $GITHUB_OUTPUT | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
file: ${{ matrix.configurations.dockerfile }} | |
push: true | |
tags: ${{ steps.combine-tags.outputs.tags }} | |
build-args: ${{ matrix.configurations.args }} | |
labels: ${{ steps.docker-meta.outputs.labels }} | |
cache-from: type=registry,ref=${{steps.combine-tags.outputs.cache_tag}} | |
cache-to: type=inline |