Files
go_blog/.gitea/workflows/go.yaml
2025-06-23 18:06:11 +08:00

35 lines
994 B
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Go build
on:
push:
branches:
- master
paths:
- 'main.go'
- '.gitea/workflows/go.yaml'
jobs:
docker:
name: build and run
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: https://gitea.com/actions/checkout@v4
- name: Set up Docker Buildx
uses: https://gitea.com/docker/setup-buildx-action@v3
- name: Build Docker image (with actor info)
run: |
# 使用GITEA_ACTOR触发CI的用户和RUN_ID生成镜像标签
docker build -t go-blog:${{ gitea.actor }}-${{ gitea.run_number }} -f ./Dockerfile .
- name: Run Docker container
run: |
# 检查并删除已存在的容器(避免冲突)
if [ $(docker ps -aq --filter name=^/goblog$) ]; then
docker stop goblog
docker rm goblog
fi
# 启动新容器并传递actor环境变量
docker run -d -p 8910:8910 --name goblog go-blog:${{ gitea.actor }}-${{ gitea.run_number }}