Initial commit: Modular personal toolbox with high-fidelity Chinese stroke order tool and CI/CD
Build and Push Docker Image / build (push) Successful in 2m30s
Build and Push Docker Image / build (push) Successful in 2m30s
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
DOCKER_HOST: unix:///var/run/docker.sock
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Log in to Gitea Registry
|
||||
run: echo "${{ secrets.PUSH_TOKEN }}" | docker login git.pengzhan.dev -u "${{ github.actor }}" --password-stdin
|
||||
|
||||
- name: Build and push Docker image
|
||||
run: |
|
||||
REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
|
||||
IMAGE_NAME="git.pengzhan.dev/$REPO_LOWER"
|
||||
|
||||
# 获取仓库的完整 URL
|
||||
REPO_URL="${{ github.server_url }}/${{ github.repository }}"
|
||||
|
||||
echo "Building image: $IMAGE_NAME with source link: $REPO_URL"
|
||||
|
||||
# 关键点:通过 --label 注入关联信息
|
||||
docker build \
|
||||
--network host \
|
||||
--label "org.opencontainers.image.source=$REPO_URL" \
|
||||
-t $IMAGE_NAME:latest \
|
||||
-t $IMAGE_NAME:${{ github.sha }} .
|
||||
|
||||
docker push $IMAGE_NAME:latest
|
||||
docker push $IMAGE_NAME:${{ github.sha }}
|
||||
Reference in New Issue
Block a user