name: Publish to GCR on: push: branches: - main - ci/* tags: pull_request: branches: - main workflow_dispatch: # concurrency: # group: ${{ github.workflow }}-${{ github.ref }}-${{github.event.inputs.runs-on }} # cancel-in-progress: false env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} PUSH_TAG: ${{github.repository}}:latest REPO: ${{github.repository}} jobs: build-and-push-image: # concurrency: # group: heavy-disk-usage # cancel-in-progress: false runs-on: "ubuntu-latest" permissions: contents: read packages: write steps: - name: Remove unnecessary run: | sudo rm -rf /usr/share/dotnet & sudo rm -rf /usr/local/lib/android & sudo rm -rf /opt/ghc & sudo rm -rf /opt/hostedtoolcache/CodeQL sudo docker image prune --all --force & - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 1 # fetch-tags: true - name: Log in to the Container registry # if: false #${{ github.event.inputs.runs-on }} uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} # https://github.com/marketplace/actions/docker-metadata-action#images-input - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v5 with: # base for tags images: | ${{ env.REGISTRY }}/${{env.IMAGE_NAME}} ${{ env.REGISTRY }}/segmentation ${{ env.REGISTRY}}/${{github.repository_owner}}/segmentation ${{ env.REGISTRY}}/${{github.repository}} tags: | type=schedule type=sha,format=short type=ref,event=branch type=ref,event=tag type=ref,event=pr type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} # set latest tag for main branch # type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} # set latest tag for default branch type=raw,value=latest,enable={{is_default_branch}} - name: Evaluate all tags run: | echo meta tags echo "${{ steps.meta.outputs.tags }}" - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Build and push Docker image uses: docker/build-push-action@v5 with: context: . push: ${{ github.event_name != 'pull_request' }} # push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels}} # build-args: HUGGINGFACE_TOKEN=${{secrets.HUGGINGFACE_TOKEN}} github-token: ${{github.token}} # cache-from: type=registry,ref=user/app:latest # cache-to: type=inline cache-from: type=registry,ref=user/app:buildcache cache-to: type=registry,ref=user/app:buildcache,mode=max # cache-from: type=gha Don't use cuz of cache limits our image size is way bigger than 10GB # cache-to: type=gha,mode=max