added temporary fix for Paragraph #84
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 EC2 | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
env: | |
FORCE_JAVASCRIPT_ACTIONS_TO_NODE20: true | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Create .env file | |
run: | | |
echo "REACT_APP_API_URL=${{ secrets.REACT_APP_API_URL }}" > .env | |
- name: Install dependencies | |
run: npm install --legacy-peer-deps | |
- name: Build the app | |
run: npm run build | |
- name: Decode SSH Key | |
run: echo "${{ secrets.EC2_SSH_KEY }}" | base64 --decode > my-website-server.pem | |
- name: Set permissions | |
run: chmod 600 my-website-server.pem | |
- name: Copy files to EC2 using SCP | |
run: | | |
scp -i my-website-server.pem -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -r build/* ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }}:/var/www/html/ | |
- name: Restart Nginx | |
run: | | |
ssh -i my-website-server.pem -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} "sudo systemctl reload nginx" |