Files
test/.gitea/workflows/manual.yaml
T
2026-07-23 17:49:59 +08:00

67 lines
1.6 KiB
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: Manual Run Build
on:
workflow_dispatch:
inputs:
# 1. 字符串(默认类型,不写 type 就是 string
image_tag:
description: "镜像 tag"
required: false
default: "latest"
# 2. 布尔
build_image:
description: "是否打镜像"
type: boolean
required: false
default: false
# 3. 数字
timeout_min:
description: "超时分钟数"
type: number
required: false
default: 10
# 4. 下拉选择(单选)
env_name:
description: "部署环境"
type: choice
options:
- dev
- test
- prod
required: true
default: dev
# 5. 环境(关联 Gitea 的 Environments 功能)
deploy_env:
description: "目标环境"
type: environment
required: false
jobs:
build:
runs-on: ubuntu-latest
container:
image: git.vipjhzf.cn/github/ci-base:latest
steps:
- name: 克隆
run: |
git clone ${{ gitea.server_url }}/${{ gitea.repository }}.git .
git checkout ${{ gitea.sha }}
- name: 编译
run: |
go mod tidy
CGO_ENABLED=0 go build -o myapp .
- name: 打镜像(仅手动触发时)
if: ${{ inputs.build_image == true }}
run: |
cat > Dockerfile <<EOF
FROM git.vipjhzf.cn/github/alpine:3.16.2
WORKDIR /app
COPY ./myapp /app/server
CMD ["/app/server"]
EOF
docker build -t myapp:${{ inputs.image_tag }} .