Merge pull request #451 from bounswe/feature/mobile-360-update-user-p… #13
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: Deploy to AWS | |
on: | |
push: | |
branches: | |
- dev | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4.1.1 | |
- name: Decrypt and Extract project_env_prod | |
run: | | |
cd ./resq/backend/resq/ | |
gpg --quiet --batch --yes --decrypt --passphrase="$RESQ_PASSPHRASE" --output project_env_prod.tar.gz project_env_prod.tar.gz.gpg | |
tar xzvf project_env_prod.tar.gz -C project_env_prod | |
env: | |
RESQ_PASSPHRASE: ${{ secrets.RESQ_PASSPHRASE }} | |
- name: Set up Docker | |
uses: docker/setup-buildx-action@v3.0.0 | |
with: | |
dockerfile: Dockerfile.remote | |
- name: Build and Push Docker Image | |
run: | | |
ls | |
cd bounswe2023group1/resq/backend/resq/ | |
docker build -t alitpc2525/resq:latest -f Dockerfile.remote . | |
docker login -u alitpc2525 -p ${{ secrets.DOCKER_PASSWORD }} | |
docker tag alitpc2525/resq:latest alitpc2525/resq:latest | |
docker push alitpc2525/resq:latest | |
- name: SSH into AWS EC2 | |
uses: appleboy/ssh-action@v1.0.0 | |
with: | |
host: ${{ secrets.AWS_EC2_HOST }} | |
username: ec2-user | |
key: ${{ secrets.AWS_PRIVATE_KEY }} | |
script: | | |
sudo service docker start | |
sudo docker rm -f $(sudo docker ps -q) | |
sudo docker pull alitpc2525/resq:latest | |
sudo docker run -d -p 443:8081 -v /home/ec2-user/certbot/keystore.p12:/app/keystore.p12 -v $(pwd)/project_env_prod:/app/project_env_prod alitpc2525/resq:latest | |
sudo docker ps |