bugfix:replace markdown exp char #52
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: | |
- master # 仅在推送到主分支时触发 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.22' | |
- name: Initialize Go modules | |
run: go mod tidy | |
- name: Build the project | |
run: go build -o chatbot | |
- name: Securely copy the binary to the server | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
REMOTE_HOST: ${{ secrets.REMOTE_HOST }} | |
REMOTE_USER: ${{ secrets.REMOTE_USER }} | |
REMOTE_PATH: /root/tgbot/chatbot | |
run: | | |
echo "${SSH_PRIVATE_KEY}" > private_key | |
chmod 600 private_key | |
scp -i private_key -o StrictHostKeyChecking=no chatbot ${REMOTE_USER}@${REMOTE_HOST}:${REMOTE_PATH} | |
- name: Restart the service on the server | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
REMOTE_HOST: ${{ secrets.REMOTE_HOST }} | |
REMOTE_USER: ${{ secrets.REMOTE_USER }} | |
run: | | |
ssh -i private_key -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} "systemctl restart tgbot" |