name: Pure Run Build on: [push] jobs: build: runs-on: ubuntu-latest steps: - name: 配置国内源并安装工具链 run: | set -e # ========== 1. 清空所有 apt 源,只留腾讯云 ========== # 备份 mkdir -p /etc/apt/backup cp -r /etc/apt/sources.list* /etc/apt/backup/ 2>/dev/null || true # 删除 sources.list.d 下所有额外源(微软 / git PPA / git-lfs 等) rm -f /etc/apt/sources.list.d/* # 清空主 sources.list,写入腾讯云 noble(24.04)源 cat > /etc/apt/sources.list <<'EOF' deb https://mirrors.cloud.tencent.com/ubuntu/ noble main restricted universe multiverse deb https://mirrors.cloud.tencent.com/ubuntu/ noble-updates main restricted universe multiverse deb https://mirrors.cloud.tencent.com/ubuntu/ noble-security main restricted universe multiverse deb https://mirrors.cloud.tencent.com/ubuntu/ noble-backports main restricted universe multiverse EOF apt-get update apt-get install -y golang-go git nodejs npm # ========== 2. 配置 Go 国内源 ========== go env -w GOPROXY=https://goproxy.cn,direct go env -w GOSUMDB=off # go env -w GOPRIVATE=git.yourdomain.com # 私有仓库按需开 # ========== 3. 配置 npm 国内源 ========== npm config set registry https://registry.npmmirror.com echo "==> 源配置完成" go version node -v npm -v - name: 克隆当前仓库 run: | git clone ${{ gitea.server_url }}/${{ gitea.repository }}.git . git checkout ${{ gitea.sha }} - name: 编译 Go 项目 run: | go mod tidy go build -o myapp . - name: 运行测试 run: | go test ./... - name: 打印完成 run: echo "构建完成 ✅" - name: 运行应用程序 run: | ./myapp