Files
bl/.github/workflows/go.yml
2025-06-30 00:40:40 +08:00

55 lines
1.6 KiB
Go
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.

# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Go
on:
push:
tags:
- 'v*'
env:
TAG_NAME: ${{ github.ref_name }} # 直接获取简化后的 ref 名称
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 缓存Go依赖
id: go-cache
uses: actions/cache@v3
with:
path: ~/go/pkg/mod # Go模块缓存路径
key: ${{ runner.os }}-go-${{ hashFiles('**/go.mod') }}
restore-keys: |
${{ runner.os }}-go-
- name: Get Tag Name
id: tag_name
run: |
echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
- name: Build logic
run: go build -o ./public/logic_${{ env.TAG }} -v ./logic
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: logic_${{ env.TAG }}
path: ./public/logic_${{ env.TAG }}
- name: Deploy to Server # 步骤3
uses: easingthemes/ssh-deploy@main # 第三方SSH部署插件
env:
SSH_PRIVATE_KEY: ${{ secrets.BLAZING }} # 从仓库密钥读取私钥
REMOTE_HOST: "82.23.177.97" # 服务器公网IP或域名
REMOTE_USER: "root" # 步骤1创建的用户
SOURCE: "public/" # 本地构建输出目录
TARGET: "/home/" # 服务器目标目录
ARGS: "-avz --chown=git:git" # rsync参数归档模式/压缩/删除多余文件