106 lines
3.6 KiB
YAML
106 lines
3.6 KiB
YAML
name: Build and Push Docker Image
|
|
run-name: ${{ gitea.actor }} is building and pushing TheChart Docker image 🚀
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- master
|
|
tags:
|
|
- "v*"
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check out repository code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0 # Fetch full history for release notes generation
|
|
|
|
- name: Install Docker
|
|
run: curl -fsSL https://get.docker.com | sh
|
|
# uses: docker/setup-docker-action@v4
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
with:
|
|
platforms: arm64,amd64
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Gitea Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: gitea-http.taildb3494.ts.net
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
|
|
- name: Extract metadata for Docker
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: gitea-http.taildb3494.ts.net/will/thechart
|
|
tags: |
|
|
type=semver,pattern={{version}}
|
|
type=ref,event=branch
|
|
type=ref,event=pr
|
|
type=sha,format=short
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64,linux/arm64/v8
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=registry,ref=gitea-http.taildb3494.ts.net/will/thechart:buildcache
|
|
cache-to: type=registry,ref=gitea-http.taildb3494.ts.net/will/thechart:buildcache,mode=max
|
|
|
|
- name: Generate release notes
|
|
id: release_notes
|
|
if: startsWith(gitea.ref, 'refs/tags/')
|
|
run: |
|
|
# Get the current tag
|
|
CURRENT_TAG=${GITEA_REF#refs/tags/}
|
|
|
|
# Get the previous tag
|
|
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
|
|
|
|
# Generate release notes from commits
|
|
if [ -n "$PREVIOUS_TAG" ]; then
|
|
echo "## Changes from $PREVIOUS_TAG to $CURRENT_TAG" > release_notes.md
|
|
echo "" >> release_notes.md
|
|
git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..$CURRENT_TAG >> release_notes.md
|
|
else
|
|
echo "## Initial Release $CURRENT_TAG" > release_notes.md
|
|
echo "" >> release_notes.md
|
|
git log --pretty=format:"- %s (%h)" >> release_notes.md
|
|
fi
|
|
|
|
# Add Docker image information
|
|
echo "" >> release_notes.md
|
|
echo "## Docker Images" >> release_notes.md
|
|
echo "" >> release_notes.md
|
|
echo "This release includes multi-platform Docker images:" >> release_notes.md
|
|
echo "- \`gitea-http.taildb3494.ts.net/will/thechart:$CURRENT_TAG\`" >> release_notes.md
|
|
echo "- \`gitea-http.taildb3494.ts.net/will/thechart:latest\`" >> release_notes.md
|
|
|
|
# Output the release notes content for use in next step
|
|
echo "release_notes<<EOF" >> $GITEA_OUTPUT
|
|
cat release_notes.md >> $GITEA_OUTPUT
|
|
echo "EOF" >> $GITEA_OUTPUT
|
|
|
|
- name: Create Release
|
|
if: startsWith(gitea.ref, 'refs/tags/')
|
|
uses: actions/create-release@v1
|
|
env:
|
|
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
|
with:
|
|
tag_name: ${{ gitea.ref_name }}
|
|
release_name: Release ${{ gitea.ref_name }}
|
|
body: ${{ steps.release_notes.outputs.release_notes }}
|
|
draft: false
|
|
prerelease: false
|