Update cd.yml to cache npm dependencies #47
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CD | |
run-name: Portfolio Deployment | |
on: | |
push: | |
branches: [ main ] | |
paths-ignore: | |
- '**/README.md' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
environment: deploy | |
steps: | |
- name: Checkout the current branch | |
uses: actions/checkout@v4 | |
- name: Initialize the ssh-agent | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: install/cache dependencies and build | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: 'npm' | |
- run: npm ci | |
- run: node --run build | |
- name: Scan the host key | |
run: mkdir -p ~/.ssh/ && ssh-keyscan -H $DEPLOY_SERVER >> ~/.ssh/known_hosts | |
env: | |
DEPLOY_SERVER: ${{ secrets.DEPLOY_SERVER }} | |
- name: Deploy the website | |
run: >- | |
rsync -avx --delete --exclude '.ssh' dist/ $DEPLOY_USERNAME@$DEPLOY_SERVER:./ | |
env: | |
DEPLOY_SERVER: ${{ secrets.DEPLOY_SERVER }} | |
DEPLOY_USERNAME: ${{ secrets.DEPLOY_USERNAME }} |