chore: switch CI to tag-triggered builds
Match the discord bot's CI pattern — trigger on CalVer tag push instead of branch push/PR. Removes auto-CalVer generation and simplifies to a single build step. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8d9bbdd7a0
commit
4ad445b0da
@ -1,20 +1,18 @@
|
|||||||
# Gitea Actions: Docker Build, Push, and Notify
|
# Gitea Actions: Docker Build, Push, and Notify
|
||||||
#
|
#
|
||||||
# CI/CD pipeline for Major Domo Database API:
|
# CI/CD pipeline for Major Domo Database API:
|
||||||
# - Builds Docker images on every push/PR
|
# - Triggered by pushing a CalVer tag (e.g., 2026.4.5)
|
||||||
# - Auto-generates CalVer version (YYYY.MM.BUILD) on main branch merges
|
# - Builds Docker image and pushes to Docker Hub with version + latest tags
|
||||||
# - Pushes to Docker Hub and creates git tag on main
|
|
||||||
# - Sends Discord notifications on success/failure
|
# - Sends Discord notifications on success/failure
|
||||||
|
#
|
||||||
|
# To release: git tag -a 2026.4.5 -m "description" && git push origin 2026.4.5
|
||||||
|
|
||||||
name: Build Docker Image
|
name: Build Docker Image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
tags:
|
||||||
- main
|
- '20*' # matches CalVer tags like 2026.4.5
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@ -24,7 +22,16 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: https://github.com/actions/checkout@v4
|
uses: https://github.com/actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Full history for tag counting
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Extract version from tag
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
VERSION=${GITHUB_REF#refs/tags/}
|
||||||
|
SHA_SHORT=$(git rev-parse --short HEAD)
|
||||||
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
echo "sha_short=$SHA_SHORT" >> $GITHUB_OUTPUT
|
||||||
|
echo "timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: https://github.com/docker/setup-buildx-action@v3
|
uses: https://github.com/docker/setup-buildx-action@v3
|
||||||
@ -35,80 +42,47 @@ jobs:
|
|||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Generate CalVer version
|
- name: Build and push Docker image
|
||||||
id: calver
|
|
||||||
uses: cal/gitea-actions/calver@main
|
|
||||||
|
|
||||||
# Dev build: push with dev + dev-SHA tags (PR/feature branches)
|
|
||||||
- name: Build Docker image (dev)
|
|
||||||
if: github.ref != 'refs/heads/main'
|
|
||||||
uses: https://github.com/docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
tags: |
|
|
||||||
manticorum67/major-domo-database:dev
|
|
||||||
manticorum67/major-domo-database:dev-${{ steps.calver.outputs.sha_short }}
|
|
||||||
cache-from: type=registry,ref=manticorum67/major-domo-database:buildcache
|
|
||||||
cache-to: type=registry,ref=manticorum67/major-domo-database:buildcache,mode=max
|
|
||||||
|
|
||||||
# Production build: push with latest + CalVer tags (main only)
|
|
||||||
- name: Build Docker image (production)
|
|
||||||
if: github.ref == 'refs/heads/main'
|
|
||||||
uses: https://github.com/docker/build-push-action@v5
|
uses: https://github.com/docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
|
manticorum67/major-domo-database:${{ steps.version.outputs.version }}
|
||||||
manticorum67/major-domo-database:latest
|
manticorum67/major-domo-database:latest
|
||||||
manticorum67/major-domo-database:${{ steps.calver.outputs.version }}
|
|
||||||
manticorum67/major-domo-database:${{ steps.calver.outputs.version_sha }}
|
|
||||||
cache-from: type=registry,ref=manticorum67/major-domo-database:buildcache
|
cache-from: type=registry,ref=manticorum67/major-domo-database:buildcache
|
||||||
cache-to: type=registry,ref=manticorum67/major-domo-database:buildcache,mode=max
|
cache-to: type=registry,ref=manticorum67/major-domo-database:buildcache,mode=max
|
||||||
|
|
||||||
- name: Tag release
|
|
||||||
if: success() && github.ref == 'refs/heads/main'
|
|
||||||
uses: cal/gitea-actions/gitea-tag@main
|
|
||||||
with:
|
|
||||||
version: ${{ steps.calver.outputs.version }}
|
|
||||||
token: ${{ github.token }}
|
|
||||||
|
|
||||||
- name: Build Summary
|
- name: Build Summary
|
||||||
run: |
|
run: |
|
||||||
echo "## Docker Build Successful" >> $GITHUB_STEP_SUMMARY
|
echo "## Docker Build Successful" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "**Version:** \`${{ steps.version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "**Image Tags:**" >> $GITHUB_STEP_SUMMARY
|
echo "**Image Tags:**" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "- \`manticorum67/major-domo-database:${{ steps.version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- \`manticorum67/major-domo-database:latest\`" >> $GITHUB_STEP_SUMMARY
|
echo "- \`manticorum67/major-domo-database:latest\`" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- \`manticorum67/major-domo-database:${{ steps.calver.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "- \`manticorum67/major-domo-database:${{ steps.calver.outputs.version_sha }}\`" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "**Build Details:**" >> $GITHUB_STEP_SUMMARY
|
echo "**Build Details:**" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- Branch: \`${{ steps.calver.outputs.branch }}\`" >> $GITHUB_STEP_SUMMARY
|
echo "- Commit: \`${{ steps.version.outputs.sha_short }}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- Commit: \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY
|
echo "- Timestamp: \`${{ steps.version.outputs.timestamp }}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- Timestamp: \`${{ steps.calver.outputs.timestamp }}\`" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
|
echo "Pull with: \`docker pull manticorum67/major-domo-database:${{ steps.version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "Pushed to Docker Hub!" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "Pull with: \`docker pull manticorum67/major-domo-database:latest\`" >> $GITHUB_STEP_SUMMARY
|
|
||||||
else
|
|
||||||
echo "_PR build - image not pushed to Docker Hub_" >> $GITHUB_STEP_SUMMARY
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Discord Notification - Success
|
- name: Discord Notification - Success
|
||||||
if: success() && github.ref == 'refs/heads/main'
|
if: success()
|
||||||
uses: cal/gitea-actions/discord-notify@main
|
uses: cal/gitea-actions/discord-notify@main
|
||||||
with:
|
with:
|
||||||
webhook_url: ${{ secrets.DISCORD_WEBHOOK }}
|
webhook_url: ${{ secrets.DISCORD_WEBHOOK }}
|
||||||
title: "Major Domo Database"
|
title: "Major Domo Database"
|
||||||
status: success
|
status: success
|
||||||
version: ${{ steps.calver.outputs.version }}
|
version: ${{ steps.version.outputs.version }}
|
||||||
image_tag: ${{ steps.calver.outputs.version_sha }}
|
image_tag: ${{ steps.version.outputs.version }}
|
||||||
commit_sha: ${{ steps.calver.outputs.sha_short }}
|
commit_sha: ${{ steps.version.outputs.sha_short }}
|
||||||
timestamp: ${{ steps.calver.outputs.timestamp }}
|
timestamp: ${{ steps.version.outputs.timestamp }}
|
||||||
|
|
||||||
- name: Discord Notification - Failure
|
- name: Discord Notification - Failure
|
||||||
if: failure() && github.ref == 'refs/heads/main'
|
if: failure()
|
||||||
uses: cal/gitea-actions/discord-notify@main
|
uses: cal/gitea-actions/discord-notify@main
|
||||||
with:
|
with:
|
||||||
webhook_url: ${{ secrets.DISCORD_WEBHOOK }}
|
webhook_url: ${{ secrets.DISCORD_WEBHOOK }}
|
||||||
|
|||||||
@ -40,7 +40,7 @@ python migrations.py # Run migrations (SQL files in migrat
|
|||||||
- **Bot container**: `dev_sba_postgres` (PostgreSQL) + `dev_sba_db_api` (API) — check with `docker ps`
|
- **Bot container**: `dev_sba_postgres` (PostgreSQL) + `dev_sba_db_api` (API) — check with `docker ps`
|
||||||
- **Image**: `manticorum67/major-domo-database:dev` (Docker Hub)
|
- **Image**: `manticorum67/major-domo-database:dev` (Docker Hub)
|
||||||
|
|
||||||
- **CI/CD**: Gitea Actions on PR to `main` — builds Docker image, auto-generates CalVer version (`YYYY.MM.BUILD`) on merge
|
- **CI/CD**: Gitea Actions — tag-triggered Docker builds. Push a CalVer tag to release: `git tag -a 2026.4.5 -m "description" && git push origin 2026.4.5`
|
||||||
|
|
||||||
## Important
|
## Important
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user