From f8461ac84992bc7deb17ccb077fcde46c6abbc8f Mon Sep 17 00:00:00 2001 From: Kelvin Obioha Date: Fri, 17 May 2024 23:22:27 +0100 Subject: [PATCH] Add github actions ci cd pipeline --- .github/workflows/ci-cd.yml | 90 +++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 .github/workflows/ci-cd.yml diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml new file mode 100644 index 0000000..d6f657e --- /dev/null +++ b/.github/workflows/ci-cd.yml @@ -0,0 +1,90 @@ +name: Smart-Exchange-Deployment + +on: + push: + branches: [main, master] + +permissions: + id-token: write + contents: read + +jobs: + Deploy: + name: Deploy to EC2 + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: SSH and Deploy + env: + PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + HOSTNAME: ${{ secrets.EC2_REMOTE_HOST }} + USER_NAME: ubuntu + + run: | + echo "$PRIVATE_KEY" > private_key && chmod 600 private_key + ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} < private_key && chmod 600 private_key +# ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} ' + +# # Now we have got the access of EC2 and we will start the deploy . +# cd /home/ubuntu/ && +# git checkout dev && +# git fetch --all && +# git reset --hard origin/dev && +# git pull origin dev && +# sudo npm i && +# sudo npm run build && +# sudo pm2 stop ./dist/index.js &&