Skip to content

chore: add log for restarting #18

chore: add log for restarting

chore: add log for restarting #18

Workflow file for this run

name: Deploy to EC2
on:
push:
branches:
- master # Replace with your branch name
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Configure SSH
env:
EC2_PRIVATE_KEY: ${{ secrets.EC2_PRIVATE_KEY }}
run: |
mkdir -p ~/.ssh
echo "$EC2_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 400 ~/.ssh/id_rsa
- name: Clone repository on EC2
env:
EC2_HOST: ${{ secrets.EC2_HOST }}
EC2_USER: ${{ secrets.EC2_USER }}
run: |
ssh -o StrictHostKeyChecking=no $EC2_USER@$EC2_HOST '
cd /home/ec2-user/rashan
git reset --hard && git clean -fd && git pull origin master
'
- name: Create .env file
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
DEPLOYMENT: ${{ secrets.DEPLOYMENT }}
run: |
echo "ACCESS_TOKEN=$ACCESS_TOKEN" > .env
echo "DEPLOYMENT=$DEPLOYMENT" >> .env
- name: Upload .env file to EC2
env:
EC2_HOST: ${{ secrets.EC2_HOST }}
EC2_USER: ${{ secrets.EC2_USER }}
run: |
scp -o StrictHostKeyChecking=no .env $EC2_USER@$EC2_HOST:/home/ec2-user/rashan/.env