Skip to content

chore: readme

chore: readme #2

Workflow file for this run

name: Deploy to EC2
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push the image
run: |
docker build -t my-python-app .
docker tag my-python-app ${{ secrets.DOCKER_USERNAME }}/my-python-app
docker push ${{ secrets.DOCKER_USERNAME }}/my-python-app
- name: Deploy to EC2
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_KEY }}
script: |
docker pull ${{ secrets.DOCKER_USERNAME }}/my-python-app
docker stop my-python-app || true
docker rm my-python-app || true
docker run -d -p 8000:8000 ${{ secrets.DOCKER_USERNAME }}/my-python-app