update route test-3 #30
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: Docker Build and Run | |
on: | |
push: | |
branches: [main] | |
jobs: | |
build_and_run: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Echo SSH_PRIVATE_KEY | |
run: echo "${{ secrets.SSH_PRIVATE_KEY }}" > key.pem | |
- name: Set up SSH | |
uses: webfactory/ssh-agent@v0.7.0 | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Pull from GitHub repository | |
run: | | |
ssh -o StrictHostKeyChecking=no -i "key.pem" ec2-user@ec2-44-206-239-176.compute-1.amazonaws.com 'cd /var/www/be-alta-quizislamic-ai && sudo git pull' | |
- name: SSH to Server, Build and Run Docker | |
run: | | |
ssh -o StrictHostKeyChecking=no -i "key.pem" ec2-user@ec2-44-206-239-176.compute-1.amazonaws.com 'cd /var/www/be-alta-quizislamic-ai/ && docker build -t docker-app-quiz-islamic-ai . && sudo docker rm -f docker-app-container || true && sudo docker run -d -p 8080:8080 --env-file .env --name docker-app-container docker-app-quiz-islamic-ai' |