Skip to content

Commit

Permalink
oper: add deploy action e rodando testes em todas branches
Browse files Browse the repository at this point in the history
  • Loading branch information
iagocpv committed Oct 23, 2024
1 parent ab6fa00 commit e13dc37
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/deployEC2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Deploy to AWS EC2
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
AWS_PRIVATE_KEY: ${{ secrets.KEYAWS }}
SSH_OPTIONS: '-o StrictHostKeyChecking=no -i key.pem ubuntu@98.80.44.121'

jobs:
deploy:
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set permissions for private key
run: |
echo "${{ env.AWS_PRIVATE_KEY }}" > key.pem
chmod 600 key.pem
- name: Create target directory on AWS instance
run: |
ssh ${{ env.SSH_OPTIONS }} 'mkdir -p /home/ubuntu/tupan-back/'
- name: Transfer code to AWS instance
run: |
scp -o StrictHostKeyChecking=no -i key.pem -r ./ ubuntu@98.80.44.121:/home/ubuntu/tupan-back
- name: Stop running containers
run: |
ssh ${{ env.SSH_OPTIONS }} 'cd /home/ubuntu/tupan-back/ && sudo docker-compose down'
- name: Run Docker Compose
run: |
ssh ${{ env.SSH_OPTIONS }} 'sudo docker-compose up'
- name: Cleanup SSH key
run: |
rm -f key.pem
4 changes: 1 addition & 3 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ name: Django CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
branches: [ "**" ]

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ version: '3'

services:
web:
image: tupan-back
build: .
command: python src/tupan/manage.py runserver 0.0.0.0:8000
volumes:
Expand Down

0 comments on commit e13dc37

Please sign in to comment.