Skip to content

Merge pull request #176 from OpenUpSA/submission-fixes #456

Merge pull request #176 from OpenUpSA/submission-fixes

Merge pull request #176 from OpenUpSA/submission-fixes #456

name: Build and Push to GHCR
on:
push:
branches: [ master, staging ]
pull_request:
branches: [ master, staging ]
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/agari-folio
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN || secrets.GITHUB_TOKEN }}
- name: Debug information
run: |
echo "Actor: ${{ github.actor }}"
echo "Repository: ${{ github.repository }}"
echo "Image name: ${{ env.IMAGE_NAME }}"
echo "Lowercase image: $(echo '${{ env.IMAGE_NAME }}' | tr '[:upper:]' '[:lower:]')"
- name: Convert image name to lowercase
id: image
run: echo "name=$(echo '${{ env.IMAGE_NAME }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ steps.image.outputs.name }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max