All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 2m58s
59 lines
1.6 KiB
YAML
59 lines
1.6 KiB
YAML
name: Build and Push Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
packages: write
|
|
contents: read
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Show commit and Dockerfile
|
|
run: git log --oneline -1 && echo "---" && head -35 Dockerfile
|
|
|
|
- name: Clear Docker build cache
|
|
run: docker builder prune -af
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Derive registry from server URL
|
|
run: |
|
|
REGISTRY=$(echo "${{ github.server_url }}" | sed 's|https://||' | sed 's|http://||')
|
|
echo "REGISTRY=${REGISTRY}" >> $GITHUB_ENV
|
|
echo "IMAGE=${REGISTRY}/${{ github.repository }}" >> $GITHUB_ENV
|
|
|
|
- name: Log in to Forgejo container registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
- name: Extract metadata (tags, labels)
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.IMAGE }}
|
|
tags: |
|
|
type=sha,prefix=,format=short
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
secrets: |
|
|
composer_auth=${{ secrets.COMPOSER_AUTH }}
|
|
no-cache: true
|