ci: 添加 Gitea Actions 示例工作流
- 新增 ci.yaml 文件,定义 Gitea Actions 示例
This commit is contained in:
@@ -1,19 +1,78 @@
|
|||||||
name: Gitea Actions Demo
|
name: Epic Go Build & Deploy
|
||||||
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
run-name: ${{ gitea.actor }} 正在构建 Epic Go 项目 🚀
|
||||||
on: [push]
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main, master, develop ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ main, master ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
Explore-Gitea-Actions:
|
build:
|
||||||
runs-on: gitea_labels
|
runs-on: gitea_labels
|
||||||
steps:
|
steps:
|
||||||
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
|
- name: 检出代码
|
||||||
- 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
|
|
||||||
uses: actions/checkout@v4
|
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: 设置 Go 环境
|
||||||
- name: List files in the repository
|
uses: actions/setup-go@v4
|
||||||
|
with:
|
||||||
|
go-version: '1.22'
|
||||||
|
cache: true
|
||||||
|
|
||||||
|
- name: 下载依赖
|
||||||
|
run: go mod download
|
||||||
|
|
||||||
|
- name: 验证依赖
|
||||||
|
run: go mod verify
|
||||||
|
|
||||||
|
- name: 构建项目
|
||||||
run: |
|
run: |
|
||||||
ls ${{ gitea.workspace }}
|
echo "🔨 开始构建 Epic Go 项目..."
|
||||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
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 }}"
|
||||||
Reference in New Issue
Block a user