docs: 修改说明文件 #77
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: Build and Deploy | |
on: | |
push: | |
branches: | |
- dev | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20' # 设置 Go 版本为 1.20 | |
- name: Install gf-tool | |
run: | | |
wget -O gf https://github.com/gogf/gf/releases/latest/download/gf_$(go env GOOS)_$(go env GOARCH) | |
chmod +x gf | |
./gf install -y | |
rm ./gf | |
- name: Build Go application | |
run: gf build | |
- name: Setup SSH | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
- name: build upload | |
run: | | |
cd ./linux_amd64 | |
tar -czf main.tar.gz main | |
scp -o StrictHostKeyChecking=no -P 22 main.tar.gz ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_HOST }}:/usr/local/kk/kkdl/main.tar.gz | |
- name: Deploy to server | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
username: ${{ secrets.SERVER_USERNAME }} | |
password: ${{ secrets.SERVER_PASSWORD }} | |
port: 22 | |
script: | | |
if [ -e /usr/local/kk/kkdl/main ]; then | |
mv /usr/local/kk/kkdl/main /usr/local/kk/kkdl/oldman | |
fi | |
cd /usr/local/kk/kkdl/ | |
tar -xzf main.tar.gz | |
sh run.sh | |
if [ -e /usr/local/kk/kkdl/oldman ]; then | |
rm -rf oldman main.tar.gz | |
fi |