Skip to content

chore: update GitHub Actions workflow to streamline branch specificat… #1

chore: update GitHub Actions workflow to streamline branch specificat…

chore: update GitHub Actions workflow to streamline branch specificat… #1

Workflow file for this run

name: Deploy to EC2 Production
on:
push:
branches: [main]
paths-ignore:
- README.md
- readme.md
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build & Push Docker Image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: devaman21/doc-analyzer:${{ github.sha }}
- name: Deploy to EC2
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.EC2_HOST }}
username: ubuntu
key: ${{ secrets.EC2_SSH_KEY }}
script: |
cd /home/ubuntu/doc-analyzer
# Update image tag in .env
sed -i "s/^IMAGE_TAG=.*/IMAGE_TAG=${{ github.sha }}/" .env
docker-compose pull
docker-compose up -d --remove-orphans
docker system prune -f