Add build
This commit is contained in:
69
.gitea/workflows/build-container-image.yml
Normal file
69
.gitea/workflows/build-container-image.yml
Normal file
@@ -0,0 +1,69 @@
|
||||
name: Docker Build & Push
|
||||
|
||||
# Trigger the workflow on pushes to the main branch
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- 'v*' # Also run on tags starting with 'v' (e.g., v1.0.0)
|
||||
|
||||
jobs:
|
||||
build-and-publish:
|
||||
# Use a standard Linux runner
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# Define variables for easy configuration
|
||||
env:
|
||||
# Replace 'gitea.local:3000' with your actual Gitea host and port (if non-standard)
|
||||
REGISTRY: git.vpn.cusano.net
|
||||
# Image name will be the Gitea repository path (e.g., username/repo-name)
|
||||
IMAGE_NAME: ${{ gitea.repository }}
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Set up QEMU for multi-architecture building (optional, but highly recommended)
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
# Set up Docker Buildx (required for multi-platform and robust builds)
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to the Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
# Use your Gitea username for the login
|
||||
username: ${{ gitea.actor }}
|
||||
# Use a Personal Access Token (PAT) stored as a Gitea Action secret
|
||||
# You MUST create a GITEA_TOKEN secret with 'write:packages' scope.
|
||||
password: ${{ secrets.BUILD_TOKEN }}
|
||||
|
||||
# Define image tags based on branch/tag information
|
||||
- name: Determine Image Tags
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=sha,prefix=,suffix=,enable=true,params=7
|
||||
type=ref,event=branch
|
||||
type=semver,pattern=v{{version}}
|
||||
|
||||
# Build and Push the Docker image
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
# Enable pushing to the registry
|
||||
push: true
|
||||
# Select platforms to build for (e.g., standard Linux amd64)
|
||||
platforms: linux/amd64, linux/arm64
|
||||
# Use the tags generated in the previous step
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
# Use the Dockerfile in the current directory (default: Dockerfile)
|
||||
file: ./Dockerfile
|
||||
# Set the build context
|
||||
context: .
|
||||
Reference in New Issue
Block a user