Skip to content

Merge pull request #22 from pmulik34/main #1

Merge pull request #22 from pmulik34/main

Merge pull request #22 from pmulik34/main #1

Workflow file for this run

name: Deploy to DEV
on:
push:
branches:
- main
jobs:
build:
name: Generate Build and Deploy to DEV
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node Env
uses: actions/setup-node@v3
with:
node-version: 16.0.0
# - name: Copy .env file
# env:
# ENV_FILE_CONTENT: ${{ secrets.env }}
# run: echo "$ENV_FILE_CONTENT" > .env
# - name: Generate React Build
# run: |
# npx update-browserslist-db@latest
# npm install @typescript-eslint/eslint-plugin --save-dev
# npm i --force
# npm run build
- name: Deploy to Server 1
uses: easingthemes/ssh-deploy@main
env:
SSH_PRIVATE_KEY: ${{ secrets.EC2_SSH_KEY }}
REMOTE_HOST: ${{ secrets.HOST_DNS }}
REMOTE_USER: ${{ secrets.USERNAME }}
TARGET: ${{ secrets.TARGET_DIR }}
- name: Set up SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.EC2_SSH_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
# Add the SSH key to the known_hosts file (replace hostname with your actual hostname)
ssh-keyscan -H ${{ secrets.HOST_DNS }} >> ~/.ssh/known_hosts
sudo apt-get install sshpass
- name: List Contents
run: |
pwd
echo "Contents of the current directory (in reverse order):"
ls -lr
# - name: List Contents
# run: |
# echo "Contents of the dist directory (in reverse order):"
# cd /home/runner/work//dragon-foods/dist
# ls -lr
- name: Deploy to server
run: |
sshpass -p '${{ secrets.EC2_SSH_KEY }}' ssh -v -o StrictHostKeyChecking=no ${{ secrets.USERNAME }}@${{ secrets.HOST_DNS }} <<'ENDSSH'
cd /opt/frontend-build
./deploy.sh
ENDSSH
# - name: Copy artifact to remote server
# run: |
# ssh ${{ secrets.USERNAME }}@${{ secrets.HOST_DNS }} 'mkdir -p /opt/artif'
# scp -r /${{ secrets.TARGET_DIR }}/runner/work/climate-res-experience-center/climate-res-experience-center/build ${{ secrets.USERNAME }}@${{ secrets.HOST_DNS }}:/var/www/climatedatahighways.becknprotocol.io.conf/public/
# sudo chown -R www-data:www-data var/www/climatedatahighways.becknprotocol.io.conf/public/build