From ab5d4f722da68ea02144e3407fa34e8ac17cc5da Mon Sep 17 00:00:00 2001 From: Preetinder Singh Date: Sat, 15 Jun 2024 04:19:21 +0530 Subject: [PATCH] Created github workflow for pull and push request --- github/workflows/check-pull-requests.yml | 27 ++++++++++++++++++++++++ github/workflows/deploy.yml | 27 ++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 github/workflows/check-pull-requests.yml create mode 100644 github/workflows/deploy.yml diff --git a/github/workflows/check-pull-requests.yml b/github/workflows/check-pull-requests.yml new file mode 100644 index 0000000..3b32868 --- /dev/null +++ b/github/workflows/check-pull-requests.yml @@ -0,0 +1,27 @@ +name: Check Pull Requests + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + lint-and-test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '14' + + - name: Install dependencies + run: npm install + + - name: Run Linter + run: npm run lint + + - name: Run Tests + run: npm test diff --git a/github/workflows/deploy.yml b/github/workflows/deploy.yml new file mode 100644 index 0000000..b09c030 --- /dev/null +++ b/github/workflows/deploy.yml @@ -0,0 +1,27 @@ +name: Deploy to Server + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up SSH + uses: webfactory/ssh-agent@v0.5.3 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + - name: Pull latest commit on server + env: + SERVER_USER: ${{ secrets.SERVER_USER }} + SERVER_HOST: ${{ secrets.SERVER_HOST }} + SERVER_PATH: ${{ secrets.SERVER_PATH }} + run: | + ssh $SERVER_USER@$SERVER_HOST 'cd $SERVER_PATH && git pull origin main && npm install && npm run build'