init
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
name: 'Build ApiServer'
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- v*
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: shiran2488/golang-with-node:1.23
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Build Action
|
||||
run: |
|
||||
go build -o quantumProfit ./cmd/main_program
|
||||
go build -o cliControl ./cmd/cli_control
|
||||
|
||||
- name: Save artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: quantumProfit
|
||||
path: |
|
||||
./quantumProfit
|
||||
./cliControl
|
||||
|
||||
deploy:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download Artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: quantumProfit
|
||||
|
||||
- name: Set up SSH
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.PUBLICT_PRIVATE_KEY }}" > ~/.ssh/id_rsa
|
||||
chmod 600 ~/.ssh/id_rsa
|
||||
# 将服务器列表写入临时文件
|
||||
echo "${{ vars.DEPLOY_SERVER_LIST }}" > server_list.txt
|
||||
# 读取文件并为每个服务器设置 SSH
|
||||
while read -r ip; do
|
||||
if [ -n "$ip" ]; then
|
||||
ssh-keyscan -H "$ip" >> ~/.ssh/known_hosts
|
||||
fi
|
||||
done < server_list.txt
|
||||
|
||||
- name: Deploy to servers
|
||||
run: |
|
||||
# 读取临时文件并循环部署
|
||||
while read -r ip; do
|
||||
if [ -n "$ip" ]; then
|
||||
echo "Deploying to $ip..."
|
||||
scp -o StrictHostKeyChecking=no quantumProfit ${{ vars.ROOT_USER_NAME }}@"$ip":/root/quantumProfit.tmp
|
||||
scp -o StrictHostKeyChecking=no cliControl ${{ vars.ROOT_USER_NAME }}@"$ip":/root/cliControl.tmp
|
||||
ssh -n ${{ vars.ROOT_USER_NAME }}@"$ip" "mv /root/quantumProfit.tmp /root/quantumProfit" < /dev/null
|
||||
ssh -n ${{ vars.ROOT_USER_NAME }}@"$ip" "mv /root/cliControl.tmp /root/cliControl" < /dev/null
|
||||
ssh -n ${{ vars.ROOT_USER_NAME }}@"$ip" "cd /root && bash ./chmodFile.sh" < /dev/null
|
||||
echo "Deployment to $ip completed"
|
||||
fi
|
||||
done < server_list.txt
|
||||
Reference in New Issue
Block a user