Go Build and Compile #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Go Build and Compile | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
# 可以添加可选的输入参数 | |
inputs: | |
reason: | |
description: 'Reason for manual run' | |
required: false | |
default: 'Manual trigger' | |
jobs: | |
build-and-compile: | |
runs-on: ubuntu-latest | |
# 设置权限,允许 push | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 # 使用最新版本 | |
- name: Set up Go environment | |
uses: actions/setup-go@v5 # 使用最新版本 | |
with: | |
go-version: '1.23' | |
check-latest: true | |
# 使用环境变量 | |
- name: Build and compile | |
env: | |
LLM_BASEURL: ${{ secrets.LLM_BASEURL }} | |
LLM_TOKEN: ${{ secrets.LLM_TOKEN }} | |
run: | | |
go build -o ./bin/starProject | |
- name: Execute compiled binary | |
env: | |
LLM_BASEURL: ${{ secrets.LLM_BASEURL }} | |
LLM_TOKEN: ${{ secrets.LLM_TOKEN }} | |
USERNAME: ${{ github.repository_owner }} | |
run: | | |
./bin/starProject | |
- name: Copy aiTagProcess.json to web/public | |
run: | | |
cp aiTagProcess.json web/public/projects.json | |
- name: Commit all files | |
# 使用 GITHUB_TOKEN 进行 git 操作 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add . | |
git commit -m "Automated commit after execution" || echo "No changes to commit" | |
git push |