Skip to content

Commit

Permalink
🚀 deploy config update
Browse files Browse the repository at this point in the history
Related:
  • Loading branch information
L-U-Ready committed Nov 11, 2024
1 parent 0f3e82f commit ce87286
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,28 @@ jobs:
run: |
echo "${{ secrets.EC2_SSH_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
- name: Connect to EC2 and deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ec2-user
key: ${{ secrets.EC2_SSH_KEY }}
script: |
# Install Docker if not installed
if ! command -v docker &> /dev/null; then
echo "Installing Docker..."
sudo amazon-linux-extras install docker -y
sudo service docker start
sudo usermod -aG docker ec2-user
fi
# Install Docker Compose if not installed
if ! command -v docker-compose &> /dev/null; then
echo "Installing Docker Compose..."
sudo curl -L "https://github.com/docker/compose/releases/download/$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep tag_name | cut -d '\"' -f 4)/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
fi
echo "Stopping and removing any existing application container..."
docker-compose -f /home/ec2-user/your_project_folder/docker-compose.yml down || true
echo "Pulling the latest Docker image..."
Expand Down

0 comments on commit ce87286

Please sign in to comment.