fix(ci): branch #1
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: CI/CD for sibylla | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: "1.17" | |
- name: Install dependencies | |
run: go mod download | |
- name: Run tests | |
run: go test ./... | |
- name: Build binary | |
run: GOOS=linux GOARCH=amd64 go build -o myapp | |
- name: Copy static files | |
run: mkdir -p static && cp -r static ./static/ | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Copy files to server | |
uses: appleboy/scp-action@v0.0.4 | |
with: | |
host: ${{ secrets.DO_DROPLET_IP }} | |
username: ${{ secrets.DO_SSH_USER }} | |
key: ${{ secrets.DO_SSH_KEY }} | |
source: "./myapp ./static/" | |
target: "/root/" | |
- name: Restart service on Droplet | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.DO_DROPLET_IP }} | |
username: ${{ secrets.DO_SSH_USER }} | |
key: ${{ secrets.DO_SSH_KEY }} | |
script: | | |
sudo systemctl restart myapp |