36 lines
1.0 KiB
YAML
36 lines
1.0 KiB
YAML
name: Build and Push Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
- main
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Log in to Gitea Container Registry
|
|
run: |
|
|
echo "${{ secrets.GITHUB_TOKEN }}" | docker login git.openlocalpdf.com -u "${{ gitea.actor }}" --password-stdin
|
|
|
|
- name: Build and Push Docker image
|
|
run: |
|
|
IMAGE_NAME="git.openlocalpdf.com/${{ gitea.repository }}"
|
|
echo "Building image: ${IMAGE_NAME}:latest"
|
|
docker build -t "${IMAGE_NAME}:latest" -f Dockerfile .
|
|
docker push "${IMAGE_NAME}:latest"
|
|
|
|
# 如果是 tag 触发,则同步打 tag 推送
|
|
if [ "${{ github.ref_type }}" = "tag" ]; then
|
|
TAG_NAME="${{ github.ref_name }}"
|
|
echo "Tag detected: ${TAG_NAME}"
|
|
docker tag "${IMAGE_NAME}:latest" "${IMAGE_NAME}:${TAG_NAME}"
|
|
docker push "${IMAGE_NAME}:${TAG_NAME}"
|
|
fi
|