SPARC/.gitea/workflows/build.yaml
0xWheatyz ead0867f4d
Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 1m57s
feat: add Gitea Actions workflow for Docker builds
Add Gitea Actions workflow to automatically build and push Docker
images to Gitea container registry.

New files:
- .gitea/workflows/build.yaml: Automated Docker build workflow
  - Triggers on push to main, tags, and manual dispatch
  - Builds Docker image from Dockerfile
  - Tags appropriately (commit SHA, tags, latest)
  - Pushes to Gitea registry at 10.0.1.10

- CONTAINER_REGISTRY.md: Complete documentation for:
  - Enabling Gitea container registry
  - Setting up CI/CD with Gitea Actions
  - Creating and using personal access tokens
  - Pulling and pushing images
  - Troubleshooting common issues

The workflow is compatible with the existing Dockerfile and provides
automated builds similar to the GitLab CI pipeline.

Prerequisites:
- Gitea container registry enabled
- GITEA_TOKEN secret configured with write:package scope

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-04 02:59:53 +00:00

78 lines
2.6 KiB
YAML

name: Build and Push Docker Image
on:
push:
branches:
- main
tags:
- '*'
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Determine image tags
id: tags
run: |
REGISTRY="10.0.1.10"
REPO_OWNER="${{ gitea.repository_owner }}"
REPO_NAME="${{ gitea.repository }}"
# Extract repository name without owner
REPO_NAME_ONLY=$(echo "$REPO_NAME" | cut -d'/' -f2)
# Base image path
IMAGE_BASE="${REGISTRY}/${REPO_OWNER}/${REPO_NAME_ONLY}"
# Determine tag based on ref
if [[ "${{ gitea.ref }}" == refs/tags/* ]]; then
# Tag push - use the tag name
TAG_NAME="${{ gitea.ref_name }}"
echo "IMAGE_TAG=${IMAGE_BASE}:${TAG_NAME}" >> $GITHUB_OUTPUT
echo "PUSH_LATEST=true" >> $GITHUB_OUTPUT
elif [[ "${{ gitea.ref_name }}" == "main" ]]; then
# Main branch - use commit SHA and latest
echo "IMAGE_TAG=${IMAGE_BASE}:${{ gitea.sha_short }}" >> $GITHUB_OUTPUT
echo "PUSH_LATEST=true" >> $GITHUB_OUTPUT
else
# Other branches - use branch name
BRANCH_TAG=$(echo "${{ gitea.ref_name }}" | sed 's/\//-/g')
echo "IMAGE_TAG=${IMAGE_BASE}:${BRANCH_TAG}" >> $GITHUB_OUTPUT
echo "PUSH_LATEST=false" >> $GITHUB_OUTPUT
fi
echo "IMAGE_LATEST=${IMAGE_BASE}:latest" >> $GITHUB_OUTPUT
- name: Log in to Gitea Container Registry
run: |
echo "${{ secrets.GITEA_TOKEN }}" | docker login 10.0.1.10 -u "${{ gitea.actor }}" --password-stdin
- name: Build Docker image
run: |
echo "Building Docker image..."
if [[ "${{ steps.tags.outputs.PUSH_LATEST }}" == "true" ]]; then
docker build -t ${{ steps.tags.outputs.IMAGE_TAG }} -t ${{ steps.tags.outputs.IMAGE_LATEST }} .
else
docker build -t ${{ steps.tags.outputs.IMAGE_TAG }} .
fi
- name: Push Docker image
run: |
echo "Pushing Docker image to registry..."
docker push ${{ steps.tags.outputs.IMAGE_TAG }}
if [[ "${{ steps.tags.outputs.PUSH_LATEST }}" == "true" ]]; then
echo "Pushing latest tag..."
docker push ${{ steps.tags.outputs.IMAGE_LATEST }}
fi
echo "Build and push completed successfully!"
echo "Image available at ${{ steps.tags.outputs.IMAGE_TAG }}"