diff --git a/.gitea/workflows/docker-build.yml b/.gitea/workflows/docker-build.yml index 0aa562a..0ad10a5 100644 --- a/.gitea/workflows/docker-build.yml +++ b/.gitea/workflows/docker-build.yml @@ -1,19 +1,18 @@ # Gitea Actions: Docker Build, Push, and Notify # # CI/CD pipeline for Major Domo Discord Bot: -# - Builds Docker images on merge to main/next-release -# - Auto-generates CalVer version (YYYY.MM.BUILD) on main branch merges -# - Supports multi-channel releases: stable (main), rc (next-release) -# - Pushes to Docker Hub and creates git tag on main +# - Triggered by pushing a CalVer tag (e.g., 2026.3.11) +# - Builds Docker image and pushes to Docker Hub with version + production tags # - Sends Discord notifications on success/failure +# +# To release: git tag 2026.3.11 && git push --tags name: Build Docker Image on: push: - branches: - - main - - next-release + tags: + - '20*' # matches CalVer tags like 2026.3.11 jobs: build: @@ -23,7 +22,16 @@ jobs: - name: Checkout code uses: https://github.com/actions/checkout@v4 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 uses: https://github.com/docker/setup-buildx-action@v3 @@ -34,67 +42,47 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} 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/major-domo-discordapp - version: ${{ steps.calver.outputs.version }} - sha_short: ${{ steps.calver.outputs.sha_short }} - - name: Build and push Docker image uses: https://github.com/docker/build-push-action@v5 with: context: . push: true - tags: ${{ steps.tags.outputs.tags }} + tags: | + manticorum67/major-domo-discordapp:${{ steps.version.outputs.version }} + manticorum67/major-domo-discordapp:production cache-from: type=registry,ref=manticorum67/major-domo-discordapp:buildcache cache-to: type=registry,ref=manticorum67/major-domo-discordapp: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 run: | echo "## Docker Build Successful" >> $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 "**Image Tags:**" >> $GITHUB_STEP_SUMMARY - IFS=',' read -ra TAG_ARRAY <<< "${{ steps.tags.outputs.tags }}" - for tag in "${TAG_ARRAY[@]}"; do - echo "- \`${tag}\`" >> $GITHUB_STEP_SUMMARY - done + echo "- \`manticorum67/major-domo-discordapp:${{ steps.version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY + echo "- \`manticorum67/major-domo-discordapp:production\`" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "**Build Details:**" >> $GITHUB_STEP_SUMMARY - echo "- Branch: \`${{ steps.calver.outputs.branch }}\`" >> $GITHUB_STEP_SUMMARY - echo "- Commit: \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY - echo "- Timestamp: \`${{ steps.calver.outputs.timestamp }}\`" >> $GITHUB_STEP_SUMMARY + echo "- Commit: \`${{ steps.version.outputs.sha_short }}\`" >> $GITHUB_STEP_SUMMARY + echo "- Timestamp: \`${{ steps.version.outputs.timestamp }}\`" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - echo "Pull with: \`docker pull manticorum67/major-domo-discordapp:${{ steps.tags.outputs.primary_tag }}\`" >> $GITHUB_STEP_SUMMARY + echo "Pull with: \`docker pull manticorum67/major-domo-discordapp:${{ steps.version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY - name: Discord Notification - Success - if: success() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/next-release') + if: success() uses: cal/gitea-actions/discord-notify@main with: webhook_url: ${{ secrets.DISCORD_WEBHOOK }} title: "Major Domo Bot" status: success - version: ${{ steps.calver.outputs.version }} - image_tag: ${{ steps.tags.outputs.primary_tag }} - commit_sha: ${{ steps.calver.outputs.sha_short }} - timestamp: ${{ steps.calver.outputs.timestamp }} + version: ${{ steps.version.outputs.version }} + image_tag: ${{ steps.version.outputs.version }} + commit_sha: ${{ steps.version.outputs.sha_short }} + timestamp: ${{ steps.version.outputs.timestamp }} - name: Discord Notification - Failure - if: failure() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/next-release') + if: failure() uses: cal/gitea-actions/discord-notify@main with: webhook_url: ${{ secrets.DISCORD_WEBHOOK }} diff --git a/CLAUDE.md b/CLAUDE.md index 3beb3d3..b0f3c5c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -16,15 +16,13 @@ manticorum67/major-domo-discordapp There is NO DASH between "discord" and "app". Not `discord-app`, not `discordapp-v2`. ### Git Workflow -NEVER commit directly to `main` or `next-release`. Always use feature branches. +NEVER commit directly to `main`. Always use feature branches. -**Branch from `next-release`** for normal work targeting the next release: ```bash -git checkout -b feature/name origin/next-release # or fix/name, refactor/name +git checkout -b feature/name origin/main # or fix/name, refactor/name ``` -**Branch from `main`** only for urgent hotfixes that bypass the release cycle. -PRs go to `next-release` (staging), then `next-release → main` when releasing. +PRs go to `main`. CI builds the Docker image and creates a CalVer tag on merge. ### Double Emoji in Embeds `EmbedTemplate.success/error/warning/info/loading()` auto-add emoji prefixes. @@ -63,13 +61,13 @@ class MyCog(commands.Cog): - **Container**: `major-domo-discord-app-1` - **Image**: `manticorum67/major-domo-discordapp` (no dash between discord and app) - **Health**: Process liveness only (no HTTP endpoint) -- **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) ### Release Workflow -1. Create feature/fix branches off `next-release` (e.g., `fix/scorebug-bugs`) -2. When done, merge the branch into `next-release` — this is the staging branch where changes accumulate -3. When ready to release, open a PR from `next-release` → `main` -4. CI builds Docker image on PR; CalVer tag is created on merge +1. Create feature/fix branches off `main` (e.g., `fix/scorebug-bugs`) +2. Open a PR to `main` when ready — merging does NOT trigger a build +3. When ready to release: `git tag YYYY.M.BUILD && git push --tags` +4. CI builds Docker image, tags it with the version + `production`, notifies Discord 5. Deploy the new image to production (see `/deploy` skill) - **Other services on same host**: `sba_db_api`, `sba_postgres`, `sba_redis`, `sba-website-sba-web-1`, `pd_api`