server change #2
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/ | |
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 | |
echo ${{ secrets.SUDO_PASSWORD }} | sudo -S systemctl stop farmec.service | |
echo ${{ secrets.SUDO_PASSWORD }} | sudo -S systemctl start farmec.service | |
echo ${{ secrets.SUDO_PASSWORD }} | sudo -S systemctl restart nginx |