Merge pull request 'ci: Use shared composite actions from cal/gitea-actions' (#18) from ci/shared-actions into main
All checks were successful
Build Docker Image / build (push) Successful in 54s
All checks were successful
Build Docker Image / build (push) Successful in 54s
Reviewed-on: #18
This commit is contained in:
commit
a44aafc940
@ -22,84 +22,56 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: https://github.com/actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Full history for tag counting
|
fetch-depth: 0 # Full history for tag counting
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: https://github.com/docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v3
|
uses: https://github.com/docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
# Generate CalVer: YYYY.MM.BUILD
|
|
||||||
# BUILD = count of tags matching current month + 1
|
|
||||||
- name: Generate CalVer version
|
- name: Generate CalVer version
|
||||||
id: meta
|
id: calver
|
||||||
run: |
|
uses: cal/gitea-actions/calver@main
|
||||||
YEAR=$(date -u +%Y)
|
|
||||||
MONTH=$(date -u +%-m)
|
|
||||||
PREFIX="${YEAR}.${MONTH}."
|
|
||||||
|
|
||||||
# Count existing tags for this month
|
|
||||||
git fetch --tags
|
|
||||||
BUILD=$(git tag -l "${PREFIX}*" | wc -l)
|
|
||||||
BUILD=$((BUILD + 1))
|
|
||||||
|
|
||||||
VERSION="${PREFIX}${BUILD}"
|
|
||||||
SHA_SHORT=$(echo ${{ github.sha }} | cut -c1-7)
|
|
||||||
|
|
||||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
|
||||||
echo "sha_short=${SHA_SHORT}" >> $GITHUB_OUTPUT
|
|
||||||
echo "version_sha=${VERSION}-${SHA_SHORT}" >> $GITHUB_OUTPUT
|
|
||||||
echo "branch=${{ github.ref_name }}" >> $GITHUB_OUTPUT
|
|
||||||
echo "timestamp=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
echo "CalVer version: ${VERSION}"
|
|
||||||
|
|
||||||
# Dev build: push with dev + dev-SHA tags (PR/feature branches)
|
# Dev build: push with dev + dev-SHA tags (PR/feature branches)
|
||||||
- name: Build Docker image (dev)
|
- name: Build Docker image (dev)
|
||||||
if: github.ref != 'refs/heads/main'
|
if: github.ref != 'refs/heads/main'
|
||||||
uses: 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:dev
|
manticorum67/major-domo-database:dev
|
||||||
manticorum67/major-domo-database:dev-${{ steps.meta.outputs.sha_short }}
|
manticorum67/major-domo-database:dev-${{ steps.calver.outputs.sha_short }}
|
||||||
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
|
||||||
|
|
||||||
# Production build: push with latest + CalVer tags (main only)
|
# Production build: push with latest + CalVer tags (main only)
|
||||||
- name: Build Docker image (production)
|
- name: Build Docker image (production)
|
||||||
if: github.ref == 'refs/heads/main'
|
if: github.ref == 'refs/heads/main'
|
||||||
uses: 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:latest
|
manticorum67/major-domo-database:latest
|
||||||
manticorum67/major-domo-database:${{ steps.meta.outputs.version }}
|
manticorum67/major-domo-database:${{ steps.calver.outputs.version }}
|
||||||
manticorum67/major-domo-database:${{ steps.meta.outputs.version_sha }}
|
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
|
||||||
|
|
||||||
# Create git tag via Gitea API (avoids branch protection issues with git push)
|
|
||||||
- name: Tag release
|
- name: Tag release
|
||||||
if: success() && github.ref == 'refs/heads/main'
|
if: success() && github.ref == 'refs/heads/main'
|
||||||
run: |
|
uses: cal/gitea-actions/gitea-tag@main
|
||||||
curl -s -X POST \
|
with:
|
||||||
-H "Authorization: token ${{ github.token }}" \
|
version: ${{ steps.calver.outputs.version }}
|
||||||
-H "Content-Type: application/json" \
|
token: ${{ github.token }}
|
||||||
-d '{
|
|
||||||
"tag_name": "${{ steps.meta.outputs.version }}",
|
|
||||||
"target": "${{ github.sha }}",
|
|
||||||
"message": "Release ${{ steps.meta.outputs.version }}"
|
|
||||||
}' \
|
|
||||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/tags"
|
|
||||||
|
|
||||||
- name: Build Summary
|
- name: Build Summary
|
||||||
run: |
|
run: |
|
||||||
@ -107,13 +79,13 @@ jobs:
|
|||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "**Image Tags:**" >> $GITHUB_STEP_SUMMARY
|
echo "**Image Tags:**" >> $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.meta.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
|
echo "- \`manticorum67/major-domo-database:${{ steps.calver.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- \`manticorum67/major-domo-database:${{ steps.meta.outputs.version_sha }}\`" >> $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.meta.outputs.branch }}\`" >> $GITHUB_STEP_SUMMARY
|
echo "- Branch: \`${{ steps.calver.outputs.branch }}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- Commit: \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY
|
echo "- Commit: \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- Timestamp: \`${{ steps.meta.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
|
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
|
||||||
echo "Pushed to Docker Hub!" >> $GITHUB_STEP_SUMMARY
|
echo "Pushed to Docker Hub!" >> $GITHUB_STEP_SUMMARY
|
||||||
@ -125,78 +97,20 @@ jobs:
|
|||||||
|
|
||||||
- name: Discord Notification - Success
|
- name: Discord Notification - Success
|
||||||
if: success() && github.ref == 'refs/heads/main'
|
if: success() && github.ref == 'refs/heads/main'
|
||||||
run: |
|
uses: cal/gitea-actions/discord-notify@main
|
||||||
curl -H "Content-Type: application/json" \
|
with:
|
||||||
-d '{
|
webhook_url: ${{ secrets.DISCORD_WEBHOOK }}
|
||||||
"embeds": [{
|
title: "Major Domo Database"
|
||||||
"title": "Major Domo Database - Build Successful",
|
status: success
|
||||||
"description": "Docker image built and pushed to Docker Hub",
|
version: ${{ steps.calver.outputs.version }}
|
||||||
"color": 3066993,
|
image_tag: ${{ steps.calver.outputs.version_sha }}
|
||||||
"fields": [
|
commit_sha: ${{ steps.calver.outputs.sha_short }}
|
||||||
{
|
timestamp: ${{ steps.calver.outputs.timestamp }}
|
||||||
"name": "Version",
|
|
||||||
"value": "`${{ steps.meta.outputs.version }}`",
|
|
||||||
"inline": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Image Tag",
|
|
||||||
"value": "`${{ steps.meta.outputs.version_sha }}`",
|
|
||||||
"inline": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Commit",
|
|
||||||
"value": "`${{ steps.meta.outputs.sha_short }}`",
|
|
||||||
"inline": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Author",
|
|
||||||
"value": "${{ github.actor }}",
|
|
||||||
"inline": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "View Run",
|
|
||||||
"value": "[Click here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})",
|
|
||||||
"inline": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": "${{ steps.meta.outputs.timestamp }}"
|
|
||||||
}]
|
|
||||||
}' \
|
|
||||||
${{ secrets.DISCORD_WEBHOOK_URL }}
|
|
||||||
|
|
||||||
- name: Discord Notification - Failure
|
- name: Discord Notification - Failure
|
||||||
if: failure() && github.ref == 'refs/heads/main'
|
if: failure() && github.ref == 'refs/heads/main'
|
||||||
run: |
|
uses: cal/gitea-actions/discord-notify@main
|
||||||
TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
with:
|
||||||
curl -H "Content-Type: application/json" \
|
webhook_url: ${{ secrets.DISCORD_WEBHOOK }}
|
||||||
-d '{
|
title: "Major Domo Database"
|
||||||
"embeds": [{
|
status: failure
|
||||||
"title": "Major Domo Database - Build Failed",
|
|
||||||
"description": "Docker build encountered an error.",
|
|
||||||
"color": 15158332,
|
|
||||||
"fields": [
|
|
||||||
{
|
|
||||||
"name": "Branch",
|
|
||||||
"value": "`${{ github.ref_name }}`",
|
|
||||||
"inline": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Commit",
|
|
||||||
"value": "`${{ github.sha }}`",
|
|
||||||
"inline": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Author",
|
|
||||||
"value": "${{ github.actor }}",
|
|
||||||
"inline": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "View Logs",
|
|
||||||
"value": "[Click here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})",
|
|
||||||
"inline": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": "'"$TIMESTAMP"'"
|
|
||||||
}]
|
|
||||||
}' \
|
|
||||||
${{ secrets.DISCORD_WEBHOOK_URL }}
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user