Files
euchre_camp/.gitea/workflows/ci-image-builder.yml
T
david 3983049d2c
Pull Request / unit-tests (pull_request) Failing after 9s
Pull Request / acceptance-tests (pull_request) Has been skipped
Pull Request / analyze-bump-type (pull_request) Has been skipped
Test / unit-tests (push) Failing after 8s
fix: use correct docker registry and image name
2026-03-31 22:19:54 -07:00

81 lines
2.7 KiB
YAML

# CI Image Builder Workflow
# Automatically builds and pushes CI images when dependencies change
# Uses GitHub Container Registry (GHCR) or any container registry
name: CI Image Builder
on:
push:
branches:
- main
paths:
- 'package.json'
- 'package-lock.json'
- 'Dockerfile.ci'
- '.gitea/workflows/ci-image-builder.yml'
workflow_dispatch:
inputs:
force_rebuild:
description: 'Force rebuild even if no changes detected'
required: false
default: 'false'
type: boolean
env:
# Use your existing Docker registry
REGISTRY: docker.notsosm.art
IMAGE_NAME: euchre-camp-ci-runner
jobs:
build-ci-image:
runs-on: ubuntu-latest
# Skip if this is an auto-generated version bump commit
if: "!contains(github.event.head_commit.message, 'chore: bump version')"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build CI image
run: |
docker build \
-f Dockerfile.ci \
-t ${{ env.IMAGE_NAME }}:latest \
-t ${{ env.IMAGE_NAME }}:$(git rev-parse --short HEAD) \
.
- name: Test CI image
run: |
docker run --rm \
${{ env.IMAGE_NAME }}:latest \
sh -c "node --version && npm --version && npx prisma --version"
- name: Push to registry
run: |
echo "Pushing to ${{ env.REGISTRY }}..."
# Check if we can authenticate to the registry using DOCKER_LOGIN and DOCKER_PASSWORD secrets
if [ -n "${{ secrets.DOCKER_LOGIN }}" ] && [ -n "${{ secrets.DOCKER_PASSWORD }}" ]; then
if docker login ${{ env.REGISTRY }} -u ${{ secrets.DOCKER_LOGIN }} -p ${{ secrets.DOCKER_PASSWORD }} 2>/dev/null; then
docker tag ${{ env.IMAGE_NAME }}:latest ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
echo "Successfully pushed CI image to ${{ env.REGISTRY }}"
else
echo "Warning: Docker login failed with provided credentials"
echo "CI image built locally but not pushed to registry"
fi
else
echo "Warning: DOCKER_LOGIN or DOCKER_PASSWORD secrets not configured"
echo "CI image built locally but not pushed to registry"
fi
- name: Show usage instructions
run: |
echo "CI Image built successfully!"
echo ""
echo "To use in workflows:"
echo " container:"
echo " image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"