Skip to content

Build and Push to GHCR #19

Build and Push to GHCR

Build and Push to GHCR #19

name: Build and Push to GHCR
on:
workflow_run:
workflows: ["Run Tests"]
types:
- completed
branches: [ develop ]
jobs:
build-push:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.PAT_TOKEN }}
- name: Convert to lowercase
id: string
uses: ASzc/change-string-case-action@v5
with:
string: ${{ github.repository }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: memory-infra/docker/Dockerfile
push: true
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
ghcr.io/${{ steps.string.outputs.lowercase }}/memory-app:${{ github.sha }}
${{ github.ref == 'refs/heads/main' && format('ghcr.io/{0}/memory-app:latest', steps.string.outputs.lowercase) || format('ghcr.io/{0}/memory-app:dev', steps.string.outputs.lowercase) }}