From 8de8913e67e5a064c245d9e72880ffe0bdc1a7a8 Mon Sep 17 00:00:00 2001 From: hu xiaotong <416314413@163.com> Date: Thu, 26 Jun 2025 12:28:51 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E6=B7=BB=E5=8A=A0=20Gitea=20Actions=20?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B=E5=B7=A5=E4=BD=9C=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 ci.yaml 文件,定义 Gitea Actions 示例 --- .gitea/workflows/ci.yaml | 85 ++++++++++++++++++++++++++++++++++------ 1 file changed, 72 insertions(+), 13 deletions(-) diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index cbf73c7..5822076 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -1,19 +1,78 @@ -name: Gitea Actions Demo -run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀 -on: [push] +name: Epic Go Build & Deploy +run-name: ${{ gitea.actor }} 正在构建 Epic Go 项目 🚀 +on: + push: + branches: [ main, master, develop ] + pull_request: + branches: [ main, master ] jobs: - Explore-Gitea-Actions: + build: runs-on: gitea_labels steps: - - run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event." - - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!" - - run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." - - name: Check out repository code + - name: 检出代码 uses: actions/checkout@v4 - - run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner." - - run: echo "🖥️ The workflow is now ready to test your code on the runner." - - name: List files in the repository + + - name: 设置 Go 环境 + uses: actions/setup-go@v4 + with: + go-version: '1.22' + cache: true + + - name: 下载依赖 + run: go mod download + + - name: 验证依赖 + run: go mod verify + + - name: 构建项目 run: | - ls ${{ gitea.workspace }} - - run: echo "🍏 This job's status is ${{ job.status }}." \ No newline at end of file + echo "🔨 开始构建 Epic Go 项目..." + go build -o epic-game-service main.go + echo "✅ 构建完成" + + - name: 列出构建产物 + run: | + echo "📦 构建产物:" + ls -la epic-game-service + + - name: 显示项目信息 + run: | + echo "📋 项目信息:" + echo "Go 版本: $(go version)" + echo "模块名称: $(go list -m)" + echo "构建时间: $(date)" + + - name: 上传构建产物 + uses: actions/upload-artifact@v4 + with: + name: epic-game-service + path: epic-game-service + retention-days: 7 + + deploy: + needs: build + runs-on: gitea_labels + if: gitea.ref == 'refs/heads/main' || gitea.ref == 'refs/heads/master' + steps: + - name: 检出代码 + uses: actions/checkout@v4 + + - name: 下载构建产物 + uses: actions/download-artifact@v4 + with: + name: epic-game-service + + - name: 部署准备 + run: | + echo "🚀 准备部署到服务器..." + echo "分支: ${{ gitea.ref }}" + echo "提交: ${{ gitea.sha }}" + echo "仓库: ${{ gitea.repository }}" + + - name: 显示部署信息 + run: | + echo "📊 部署信息:" + echo "运行器操作系统: ${{ runner.os }}" + echo "工作目录: ${{ gitea.workspace }}" + echo "任务状态: ${{ job.status }}" \ No newline at end of file