Skip to content

Hotfix: Change cmd #104

Hotfix: Change cmd

Hotfix: Change cmd #104

Workflow file for this run

name: Django Tests
on:
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m venv venv
source venv/bin/activate
pip install django
- name: Change directory
run: |
source venv/bin/activate
python -m pip install Pillow
cd pure_plate
deploy:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build and push Docker image
run: |
cd pure_plate
docker build -t pure_plate_init .
docker tag pure_plate_init ${{ secrets.DOCKER_USERNAME }}/pure_plate:latest
docker push ${{ secrets.DOCKER_USERNAME }}/pure_plate:latest
- name: Set up SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.EC2_KEY }}
- name: Deploy to EC2
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} << 'EOF'
docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/pure_plate
docker stop django_pure_plate || true
docker rm django_pure_plate || true
docker run -d --name django_pure_plate -p 80:80 -e DJANGO_SETTINGS_MODULE=pure_plate.settings ${{ secrets.DOCKER_HUB_USERNAME }}/pure_plate:latest
EOF