use scp to copy files #5
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: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: '1.22.4' | |
- name: Build Server | |
run: go build cmd/server/server.go | |
- name: Build Scheduler | |
run: go build cmd/scheduler/scheduler.go | |
- name: Deploy and Start Services | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.SERVER }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
port: 22 | |
script: | | |
sudo scp server /usr/local/bin/ | |
sudo scp scheduler /usr/local/bin/ | |
sudo chown appuser:appuser /usr/local/bin/server | |
sudo chown appuser:appuser /usr/local/bin/scheduler | |
sudo systemctl start scheduler | |
sudo systemctl enable scheduler | |
sudo systemctl start server | |
sudo systemctl enable server |