Portfolio Deployment #43
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 npm, astro & build | |
run: | | |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash | |
source ~/.bashrc | |
export NVM_DIR="$HOME/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm | |
nvm install node | |
npm install | |
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 }} |