diff --git a/GitHub/workflows/deploy.yml b/GitHub/workflows/deploy.yml new file mode 100644 index 0000000..9367225 --- /dev/null +++ b/GitHub/workflows/deploy.yml @@ -0,0 +1,27 @@ +name: Deploy Project + +on: + push: + branches: [main] + +jobs: + deploy: + runs-on: ubuntu-latest + container: + image: node:20 + steps: + - uses: actions/checkout@v3 + with: + node-versions: 20 + - run: npm ci + - run: npm run build + - name: Get SSH Key and set up permissions + run: + mkdir -p ~/.ssh + echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa + - name: Deploy using SCP + run: scp -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa -r ./dist/* ${{ secrets.SSH_USER }}@${{ secrets.SSH_Host }}:~/node-app + - name: Restart Server + run: ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa ${{ secrets.SSH_USER }}@${{ secrets.SSH_Host }} "cd ~/node-app && npm install && pm2 restart 0" + + diff --git a/GitHub/workflows/test.yml b/GitHub/workflows/test.yml new file mode 100644 index 0000000..480c560 --- /dev/null +++ b/GitHub/workflows/test.yml @@ -0,0 +1,18 @@ +name: Test Project + +on: + pull_request: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + image: node:20 + steps: + - uses: actions/checkout@v3 + with: + node-versions: 20 + - run: npm ci + - run: npm test + - run: npm run build +