testing #8
This file contains hidden or 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 to EC2 | |
on: | |
push: | |
branches: [ master ] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to EC2 | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ec2-user | |
key: ${{ secrets.EC2_SSH_KEY }} | |
script: | | |
# Navigate to your project directory | |
cd /home/ec2-user/golang-project | |
# Pull the latest changes | |
git pull origin master | |
# Stop the current process | |
sudo pkill main || true | |
sudo fuser -k 8080/tcp || true | |
sleep 2 | |
# Build the application | |
go build -o main cmd/api/main.go | |
# Start the application in the background | |
nohup ./main -config config/local.yaml > output.log 2>&1 & |