40 lines
1.0 KiB
YAML
40 lines
1.0 KiB
YAML
name: Manual Run Build
|
|
on:
|
|
push:
|
|
workflow_dispatch:
|
|
inputs:
|
|
build_image:
|
|
description: "是否编译并推送 Docker 镜像"
|
|
required: false
|
|
default: "false"
|
|
image_tag:
|
|
description: "自定义镜像 tag"
|
|
required: false
|
|
default: "manual"
|
|
|
|
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 }} . |