Some checks failed
Go CI/CD Pipeline / Lint and Format (push) Successful in 4m51s
Docker Build and Publish / Version Bump (push) Successful in 4m54s
Docker Build and Publish / Build and Push Docker Image (push) Failing after 2m51s
Go CI/CD Pipeline / Build and Test (push) Successful in 9m47s
Go CI/CD Pipeline / Version Management (push) Successful in 12s
- Add swag fmt to git pre-commit hook and CI/CD pipeline - Create comprehensive CONTRIBUTING.md guide with AI section - Update ADR-0013 with swag fmt documentation - Fix swagger generation to include all endpoints - Improve local testing scripts and workflows - Update Dockerfile for better swagger handling - Fix CI/CD workflow file references
140 lines
4.9 KiB
YAML
140 lines
4.9 KiB
YAML
---
|
|
# DanceLessonsCoach Docker Image Build Workflow
|
|
# Based on Arcodange webapp conventions
|
|
# Builds and publishes Docker images to Gitea Container Registry
|
|
|
|
name: Docker Build and Publish
|
|
|
|
on:
|
|
workflow_dispatch: {}
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- 'v*.*.*'
|
|
paths-ignore:
|
|
- 'README.md'
|
|
- 'doc/**'
|
|
- 'adr/**'
|
|
- '.gitea/**'
|
|
|
|
# cancel any previously-started, yet still active runs of this workflow on the same branch
|
|
concurrency:
|
|
group: ${{ github.ref }}-${{ github.workflow }}
|
|
cancel-in-progress: true
|
|
|
|
# Arcodange-specific environment variables
|
|
env:
|
|
GITEA_INTERNAL: "https://gitea.arcodange.lab/"
|
|
GITEA_EXTERNAL: "https://gitea.arcodange.fr/"
|
|
GITEA_ORG: "arcodange"
|
|
GITEA_REPO: "DanceLessonsCoach"
|
|
CI_REGISTRY: "gitea.arcodange.lab"
|
|
|
|
jobs:
|
|
version-bump:
|
|
name: Version Bump
|
|
runs-on: ubuntu-latest
|
|
if: github.ref == 'refs/heads/main'
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version: '1.26.1'
|
|
|
|
- name: Install swag and generate Swagger Docs
|
|
run: |
|
|
if [ ! -f pkg/server/docs/swagger.json ]; then
|
|
echo "📝 Generating Swagger documentation..."
|
|
go install github.com/swaggo/swag/cmd/swag@latest
|
|
cd pkg/server && go generate
|
|
echo "✅ Swagger documentation generated"
|
|
else
|
|
echo "✅ Swagger documentation already exists, skipping generation"
|
|
fi
|
|
|
|
- name: Bump version based on commit type
|
|
run: |
|
|
# Analyze last commit message
|
|
LAST_COMMIT=$(git log -1 --pretty=%B | head -1)
|
|
|
|
if echo "$LAST_COMMIT" | grep -q "^feat:"; then
|
|
echo "🎯 Feature commit detected - bumping MINOR version"
|
|
./scripts/version-bump.sh minor
|
|
elif echo "$LAST_COMMIT" | grep -q "^fix:"; then
|
|
echo "🐛 Fix commit detected - bumping PATCH version"
|
|
./scripts/version-bump.sh patch
|
|
elif echo "$LAST_COMMIT" | grep -q "BREAKING CHANGE"; then
|
|
echo "💥 Breaking change detected - bumping MAJOR version"
|
|
./scripts/version-bump.sh major
|
|
else
|
|
echo "⏭️ No automatic version bump needed"
|
|
# Still ensure swagger version is updated
|
|
source VERSION
|
|
NEW_VERSION="$MAJOR.$MINOR.$PATCH${PRERELEASE:+-$PRERELEASE}"
|
|
sed -i "s|// @version [0-9.]*|// @version $NEW_VERSION|" cmd/server/main.go
|
|
fi
|
|
|
|
- name: Commit version changes
|
|
run: |
|
|
git config --global user.name "CI Bot"
|
|
git config --global user.email "ci@arcodange.fr"
|
|
git add VERSION cmd/server/main.go
|
|
git commit -m "chore: auto version bump [skip ci]" || echo "No changes to commit"
|
|
git push
|
|
|
|
build-and-push-image:
|
|
name: Build and Push Docker Image
|
|
runs-on: ubuntu-latest
|
|
needs: version-bump
|
|
if: always() && (needs.version-bump.result == 'success' || needs.version-bump.result == 'skipped')
|
|
|
|
steps:
|
|
- name: Login to Gitea Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.CI_REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.PACKAGES_TOKEN }}
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build and push image to Gitea Container Registry
|
|
run: |-
|
|
# Determine tags based on event type
|
|
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
|
|
# For tags, use the tag name and latest
|
|
TAGS="${{ github.ref_name }} latest"
|
|
else
|
|
# For main branch, use commit SHA and latest
|
|
TAGS="latest ${{ github.sha }}"
|
|
fi
|
|
|
|
echo "Building Docker image with tags: $TAGS"
|
|
docker build -t dance-lessons-coach .
|
|
|
|
for TAG in $TAGS; do
|
|
IMAGE_NAME="${{ env.CI_REGISTRY }}/${{ env.GITEA_ORG }}/${{ env.GITEA_REPO }}:$TAG"
|
|
echo "Tagging and pushing: $IMAGE_NAME"
|
|
docker tag dance-lessons-coach "$IMAGE_NAME"
|
|
docker push "$IMAGE_NAME"
|
|
done
|
|
|
|
- name: Show published images
|
|
run: |-
|
|
echo "📦 Published Docker images:"
|
|
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
|
|
echo " - ${{ env.CI_REGISTRY }}/${{ env.GITEA_ORG }}/${{ env.GITEA_REPO }}:${{ github.ref_name }}"
|
|
echo " - ${{ env.CI_REGISTRY }}/${{ env.GITEA_ORG }}/${{ env.GITEA_REPO }}:latest"
|
|
else
|
|
echo " - ${{ env.CI_REGISTRY }}/${{ env.GITEA_ORG }}/${{ env.GITEA_REPO }}:latest"
|
|
echo " - ${{ env.CI_REGISTRY }}/${{ env.GITEA_ORG }}/${{ env.GITEA_REPO }}:${{ github.sha }}"
|
|
fi |