name: publish seed-vc Docker Image on: workflow_dispatch: {} push: paths: - "voice_conversion/seed-vc/**" branches: # NB: Default-branch doesn't work, despite Github's documentation. #- $default-branch - master env: IMAGE_NAME: seed-vc jobs: # Push image to GitHub Packages. # See also https://docs.docker.com/docker-hub/builds/ docker-build-and-push: runs-on: ubuntu-latest permissions: packages: write contents: read steps: - uses: actions/checkout@v2 - name: Login to GitHub Container Registry uses: docker/login-action@v1 with: registry: ghcr.io #username: ${{ github.repository_owner }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Free Disk Space (Ubuntu) uses: jlumbroso/free-disk-space@main with: tool-cache: false android: true dotnet: true haskell: true large-packages: false docker-images: false swap-storage: false - name: Build image run: | echo "check available disk space" cd voice_conversion/seed-vc && ls -alt && docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" - name: Push image to GitHub Container Registry run: | IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME # Change all uppercase to lowercase IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') # Strip git ref prefix from version VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') # Strip "v" prefix from tag name [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') # Use Docker `latest` tag convention [ "$VERSION" == "$default-branch" ] && VERSION=latest echo IMAGE_ID=$IMAGE_ID echo VERSION=$VERSION docker tag $IMAGE_NAME $IMAGE_ID:$VERSION docker push $IMAGE_ID:$VERSION SHORT_SHA=$(echo ${GITHUB_SHA} | cut -c1-12) docker tag $IMAGE_NAME $IMAGE_ID:$SHORT_SHA docker push $IMAGE_ID:$SHORT_SHA