Some checks failed
Build and Push Docker Image / build-and-push-image (push) Has been cancelled
63 lines
2.3 KiB
YAML
63 lines
2.3 KiB
YAML
# =============================================================================
|
|
# Forgejo Actions workflow to build and push Docker image
|
|
# =============================================================================
|
|
# Triggered on push to main or master branches
|
|
# -----------------------------------------------------------------------------
|
|
|
|
name: Build and Push Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- master
|
|
|
|
jobs:
|
|
build-and-push-image:
|
|
runs-on: docker
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
# -------------------------------------------------------------------------
|
|
# Check out repository code
|
|
# -------------------------------------------------------------------------
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
# -------------------------------------------------------------------------
|
|
# Install Docker CLI (not cached in image, needed for buildx)
|
|
# -------------------------------------------------------------------------
|
|
- name: Install Docker
|
|
run: |
|
|
apt-get update -qq
|
|
apt-get install -y --no-install-recommends docker.io
|
|
|
|
# -------------------------------------------------------------------------
|
|
# Set up Docker Buildx for layer caching
|
|
# -------------------------------------------------------------------------
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
# -------------------------------------------------------------------------
|
|
# Authenticate with Forgejo container registry
|
|
# -------------------------------------------------------------------------
|
|
- name: Login to Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: git.workaround.org
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.FORGEJO_TOKEN }}
|
|
|
|
# -------------------------------------------------------------------------
|
|
# Build and push image with GitHub Actions cache
|
|
# -------------------------------------------------------------------------
|
|
- name: Build and Push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: git.workaround.org/${{ github.repository }}:latest
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|