Skip to content

fix: build docker

fix: build docker #52

Workflow file for this run

name: Docker Image CI
on:
push:
branches:
- main
env:
TZ: Asia/Shanghai
jobs:
check_commit:
name: Check if commit should trigger release
runs-on: ubuntu-latest
outputs:
should_release: ${{ steps.check.outputs.should_release }}
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Check commit message
id: check
run: |
commit_message="${{ github.event.head_commit.message }}"
echo "Commit message: $commit_message"
# 检查是否包含触发版本更新的关键字
if echo "$commit_message" | grep -qE "^(feat|fix|perf|revert):"; then
echo "should_release=true" >> $GITHUB_OUTPUT
echo "✅ Found release trigger in commit message"
else
echo "should_release=false" >> $GITHUB_OUTPUT
echo "❌ No release trigger found in commit message"
fi
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
needs: check_commit
if: needs.check_commit.outputs.should_release == 'true'
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: fevrax/json-tools
tags: |
type=raw,value=latest
type=ref,event=tag
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64
push: true
tags: fevrax/json-tools:latest
labels: ${{ steps.meta.outputs.labels }}
cache-from: |
type=gha,scope=${{ github.ref_name }}-${{ github.workflow }}
type=registry,ref=fevrax/json-tools:latest
cache-to: |
type=gha,scope=${{ github.ref_name }}-${{ github.workflow }},mode=max