Skip to content

Update cd.yml to cache npm dependencies #47

Update cd.yml to cache npm dependencies

Update cd.yml to cache npm dependencies #47

Workflow file for this run

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 }}