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: Netflix Movie Catalog Service Deployment | |
on: | |
push: | |
branches: | |
- main | |
env: | |
EC2_PUBLIC_IP: ec2-18-191-150-153.us-east-2.compute.amazonaws.com # TODO replace to your EC2 instance public IP | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} # TODO define this secret in your GitHub repo settings | |
jobs: | |
Deploy: | |
name: Deploy in EC2 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the app code | |
uses: actions/checkout@v2 | |
- name: SSH to EC2 instance | |
run: | | |
echo "$SSH_PRIVATE_KEY" > mykey.pem | |
chmod 600 mykey.pem | |
# Copy the files from the current work dir into the EC2 instance, under `~/home/ubuntu/NetflixMovieCatalog`. | |
scp -o StrictHostKeyChecking=no -i mykey.pem -r * ubuntu@$EC2_PUBLIC_IP:~/NetflixMovieCatalog/ | |
# Connect to your EC2 instance and execute the `deploy.sh` script (this script is part of the repo files). | |
# TODO You need to implement the `deploy.sh` script yourself. | |
# | |
# Upon completion, the NetflixMovieCatalog app should be running with its newer version. | |
# To keep the app running in the background independently on the terminal session you are logging to, configure it as a Linux service. | |
ssh -i mykey.pem ubuntu@$EC2_PUBLIC_IP "bash ~/NetflixMovieCatalog/deploy.sh" | |