From 9b4636ed686c35a562d55a4037c46d6ce35f90d9 Mon Sep 17 00:00:00 2001 From: Justin Liao Date: Thu, 29 Feb 2024 14:24:59 -0800 Subject: [PATCH] Edit README.md and add template CD.yml --- .github/workflows/CD.yml | 30 ++++++++++++++++++++++++++++++ README.md | 6 +++--- 2 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/CD.yml diff --git a/.github/workflows/CD.yml b/.github/workflows/CD.yml new file mode 100644 index 0000000..c3e7b53 --- /dev/null +++ b/.github/workflows/CD.yml @@ -0,0 +1,30 @@ +name: EC2 Deploy + +on: + push: + branches: [dev-deployment] + +jobs: + Deploy: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Deploy in EC2 + env: + PRIVATE_KEY: ${{ secrets.AWS_EC2_PRIVATE_KEY }} + HOSTNAME : ${{ secrets.AWS_EC2_HOSTNAME }} + USER: ${{ secrets.AWS_EC2_USER }} + + run: | + echo "$PRIVATE_KEY" > private_key.pem && chmod 600 private_key.pem + ssh -o StrictHostKeyChecking=no -i private_key.pem ${USER}@${HOSTNAME} ' + + #Now we have got the access of EC2 and we will start the deploy . + cd ~/npo-backend-template && + git checkout dev && + git stash && + git pull origin dev && + yarn && + pm2 restart app.js + ' diff --git a/README.md b/README.md index e5254c1..53c7edc 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,9 @@ This template will be used to create all NPO backend repos To start working on with this project, follow these steps: 1. Install the [EditorConfig plugin](https://editorconfig.org/#download) for your IDE. -1. Add the `.env` file stored in your projects Google Drive folder to the root of the project. -1. Install NodeJS and yarn following the [instructions here](https://classic.yarnpkg.com/lang/en/docs/install). -1. Navigate to the project folder in your terminal and run `yarn` to install required packages. +2. Install NodeJS and yarn following the [instructions here](https://classic.yarnpkg.com/lang/en/docs/install). +3. Configure environment variables with `dotenv-vault` ([install here](https://www.dotenv.org/docs#getting-started)) following [instructions here](https://www.dotenv.org/docs/quickstart/sync#pull-env). +4. Navigate to the project folder in your terminal and run `yarn` to install required packages. ## Project branching structure