Merge pull request #41 from PlanIt-Project/BE_feature_36 #5
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 EC2 | |
on: | |
push: | |
branches: | |
- test | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Docker Environment | |
run: | | |
touch ./.env | |
echo "DATABASE_URL=${{ secrets.MYSQL_DB_URL }}" >> .env | |
echo "DATABASE_USERNAME=${{ secrets.DB_USER }}" >> .env | |
echo "DATABASE_PASSWORD=${{ secrets.DB_PASSWORD }}" >> .env | |
shell: bash | |
- name: Build and Push Docker image | |
run: | | |
docker-compose build | |
docker-compose up -d | |
- name: Deploy to EC2 | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ${{ secrets.EC2_USER }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
script: | | |
docker-compose down | |
docker-compose up -d |