Files
userbase/.gitea/workflows/example-docker.yml
T

48 lines
1.8 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: example-docker-push
# 示例:演示 act_runner 的 docker.sock 能力(构建并推送镜像到 Nexus docker-hosted)
# 需要仓库 Settings -> Actions Secrets 配置:
# NEXUS_USER = admin
# NEXUS_PASSWORD = <nexus admin password>
# 手动触发(Actions 页面 -> Run workflow),不会自动跑。
on:
workflow_dispatch:
inputs:
tag:
description: 'image tag to push'
required: false
default: 'demo'
jobs:
docker-build-push:
runs-on: ubuntu-latest
# docker:24 自带 docker CLI,复用宿主 docker daemon
# docker.sock 显式挂入 job 容器(act_runner 会校验 valid_volumes 白名单)
container:
image: docker:24
volumes:
- /var/run/docker.sock:/var/run/docker.sock
steps:
# docker:24 基于 alpine,默认无 git;先装 git 再手动 clone 本仓库
- name: Install git (alpine)
run: |
# 统一走 aliyun 源:dl-cdn 时段性被拦会卡满 60s×2(2026-10-20 事故)
sed -i 's#dl-cdn.alpinelinux.org#mirrors.aliyun.com#g' /etc/apk/repositories
apk add --no-cache git
# 内网 Gitea 无法访问 github.com 拉取 actions/checkout,改为直接 clone 本仓库
- name: Checkout (manual, internal Gitea)
run: |
git clone --depth 1 --branch main http://192.168.10.160:3000/${GITHUB_REPOSITORY}.git /tmp/src
cp -a /tmp/src/. .
rm -rf /tmp/src
- name: Login to Nexus docker registry
run: echo "${{ secrets.NEXUS_PASSWORD }}" | docker login nexus:8083 -u ${{ secrets.NEXUS_USER }}
- name: Build image (front nginx)
run: docker build -t nexus:8083/docker-hosted/userbase-front:${{ inputs.tag }} -f front/docker/Dockerfile front
- name: Push image
run: docker push nexus:8083/docker-hosted/userbase-front:${{ inputs.tag }}