return to 443 #128
Workflow file for this run
This file contains 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: Django Tests | |
on: | |
push: | |
branches: | |
- newport | |
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 | |
pip install django-cors-headers | |
- 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 pureplate-backend_init . | |
docker tag pureplate-backend_init ${{ secrets.DOCKER_HUB_USERNAME }}/pureplate-backend:latest | |
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/pureplate-backend: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 }}/pureplate-backend:latest | |
docker stop django_pure_plate || true | |
docker rm django_pure_plate || true | |
docker run -d --name django_pure_plate -p 443:8000 -e DJANGO_SETTINGS_MODULE=pure_plate.settings ${{ secrets.DOCKER_HUB_USERNAME }}/pureplate-backend:latest | |
EOF |