ci: switch to tag-based Docker builds

Replace branch/PR-triggered Docker builds with tag-only triggers.
Images are now built only when a CalVer tag is pushed
(git tag YYYY.M.BUILD && git push origin YYYY.M.BUILD).

- Remove calver, docker-tags, and gitea-tag reusable actions
- Add inline version extraction from tag ref
- Keep existing build cache config
- Update CLAUDE.md versioning and CI/CD sections

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2026-03-23 10:46:55 -05:00
parent e2ddaf75b7
commit fcd2e33916
2 changed files with 34 additions and 47 deletions

View File

@ -1,21 +1,18 @@
# Gitea Actions: Docker Build, Push, and Notify # Gitea Actions: Docker Build, Push, and Notify
# #
# CI/CD pipeline for Paper Dynasty Discord Bot: # CI/CD pipeline for Paper Dynasty Discord Bot:
# - Builds Docker images on every push/PR # - Triggered by pushing a CalVer tag (e.g., 2026.3.11)
# - Auto-generates CalVer version (YYYY.MM.BUILD) on main branch merges # - Builds Docker image and pushes to Docker Hub with version + production 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 2026.3.11 && git push origin 2026.3.11
name: Build Docker Image name: Build Docker Image
on: on:
push: push:
branches: tags:
- main - '20*' # matches CalVer tags like 2026.3.11
- next-release
pull_request:
branches:
- main
jobs: jobs:
build: build:
@ -25,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
@ -36,67 +42,47 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Generate CalVer version
id: calver
uses: cal/gitea-actions/calver@main
- name: Resolve Docker tags
id: tags
uses: cal/gitea-actions/docker-tags@main
with:
image: manticorum67/paper-dynasty-discordapp
version: ${{ steps.calver.outputs.version }}
sha_short: ${{ steps.calver.outputs.sha_short }}
- name: Build and push Docker image - name: Build and push Docker image
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: ${{ steps.tags.outputs.tags }} tags: |
manticorum67/paper-dynasty-discordapp:${{ steps.version.outputs.version }}
manticorum67/paper-dynasty-discordapp:production
cache-from: type=registry,ref=manticorum67/paper-dynasty-discordapp:buildcache cache-from: type=registry,ref=manticorum67/paper-dynasty-discordapp:buildcache
cache-to: type=registry,ref=manticorum67/paper-dynasty-discordapp:buildcache,mode=max cache-to: type=registry,ref=manticorum67/paper-dynasty-discordapp:buildcache,mode=max
- name: Tag release
if: success() && steps.tags.outputs.channel == 'stable'
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 "**Channel:** \`${{ steps.tags.outputs.channel }}\`" >> $GITHUB_STEP_SUMMARY echo "**Version:** \`${{ steps.version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY
echo "**Image Tags:**" >> $GITHUB_STEP_SUMMARY echo "**Image Tags:**" >> $GITHUB_STEP_SUMMARY
IFS=',' read -ra TAG_ARRAY <<< "${{ steps.tags.outputs.tags }}" echo "- \`manticorum67/paper-dynasty-discordapp:${{ steps.version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
for tag in "${TAG_ARRAY[@]}"; do echo "- \`manticorum67/paper-dynasty-discordapp:production\`" >> $GITHUB_STEP_SUMMARY
echo "- \`${tag}\`" >> $GITHUB_STEP_SUMMARY
done
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
echo "Pull with: \`docker pull manticorum67/paper-dynasty-discordapp:${{ steps.tags.outputs.primary_tag }}\`" >> $GITHUB_STEP_SUMMARY echo "Pull with: \`docker pull manticorum67/paper-dynasty-discordapp:${{ steps.version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
- name: Discord Notification - Success - name: Discord Notification - Success
if: success() && steps.tags.outputs.channel != 'dev' 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: "Paper Dynasty Bot" title: "Paper Dynasty Bot"
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() && steps.tags.outputs.channel != 'dev' 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 }}

View File

@ -32,7 +32,7 @@ pip install -r requirements.txt # Install dependencies
- **Container**: `paper-dynasty_discord-app_1` - **Container**: `paper-dynasty_discord-app_1`
- **Image**: `manticorum67/paper-dynasty-discordapp` - **Image**: `manticorum67/paper-dynasty-discordapp`
- **Health**: `GET http://localhost:8080/health` (HTTP server in `health_server.py`) - **Health**: `GET http://localhost:8080/health` (HTTP server in `health_server.py`)
- **Versioning**: CalVer (`YYYY.MM.BUILD`) — auto-generated on merge to `main` - **Versioning**: CalVer (`YYYY.M.BUILD`) — manually tagged when ready to release
### Logs ### Logs
- **Container logs**: `ssh sba-bots "docker logs --since 1h paper-dynasty_discord-app_1"` - **Container logs**: `ssh sba-bots "docker logs --since 1h paper-dynasty_discord-app_1"`
@ -49,8 +49,9 @@ pip install -r requirements.txt # Install dependencies
- Health endpoint not responding → `health_server.py` runs on port 8080 inside the container - Health endpoint not responding → `health_server.py` runs on port 8080 inside the container
### CI/CD ### CI/CD
Gitea Actions on PR to `main` — builds Docker image, auto-generates CalVer version on merge. Ruff lint on PRs. Docker image built on CalVer tag push only.
```bash ```bash
# Release: git tag YYYY.M.BUILD && git push origin YYYY.M.BUILD
tea pulls create --repo cal/paper-dynasty --head <branch> --base main --title "title" --description "description" tea pulls create --repo cal/paper-dynasty --head <branch> --base main --title "title" --description "description"
``` ```