ci: add Gitea Actions workflow for container build and registry publish
This commit is contained in:
@@ -0,0 +1,36 @@
|
|||||||
|
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"
|
||||||
|
REPO_URL="${{ github.server_url }}/${{ github.repository }}"
|
||||||
|
|
||||||
|
echo "Building image: $IMAGE_NAME with source link: $REPO_URL"
|
||||||
|
|
||||||
|
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