Skip to content

Workflow file for this run

name: 'Build and Deploy - Embedder'
on:
workflow_dispatch:
push:
branches: [main]
pull_request:
branches: [main]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
ENV_STAGE: stage
jobs:
build-and-push-to-ghcr:
name: Build
runs-on: ubuntu-20.04
permissions:
contents: read
packages: write
outputs:
tag: ${{ steps.prep.outputs.tag }}
steps:
- uses: actions/checkout@v2
- id: prep
run: |
TAG=$(echo $GITHUB_SHA | head -c7)
IMAGE="${{ env.REGISTRY }}/edenartlab/embedder"
echo ::set-output name=tagged_image::${IMAGE}:${TAG}
echo ::set-output name=tag::${TAG}
echo ::set-output name=image::${IMAGE}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Log in to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: true
tags:
${{ steps.prep.outputs.tagged_image }},${{ steps.prep.outputs.image
}}:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache