github actions #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: Deploy Go Application | |
'on': | |
push: | |
paths: | |
- server/** | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Copy files to EC2 | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ${{ secrets.EC2_USER }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
port: ${{ secrets.SSH_PORT }} | |
source: server/,other-configs/ | |
target: /home/seanwelch/ | |
script: | | |
echo "Listing files in /home/seanwelch/" | |
ls -lah /home/seanwelch/ | |
cd /home/seanwelch/server | |
- name: Build Go binary, restart application and Nginx | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ${{ secrets.EC2_USER }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
port: ${{ secrets.SSH_PORT }} | |
script: | | |
cd ./server | |
source ~/.profile | |
go build -o bin/main | |
sudo systemctl stop farmec.service | |
sudo systemctl start farmec.service | |
sudo systemctl restart nginx |