Skip to content

Instantly share code, notes, and snippets.

@Valexr
Created February 2, 2023 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Valexr/62b3493d73f54389f3221ed53fef298d to your computer and use it in GitHub Desktop.
Save Valexr/62b3493d73f54389f3221ed53fef298d to your computer and use it in GitHub Desktop.
name: Deploy
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '18.13.0'
- run: npm i
- run: npm run build
# Setup key
- run: set -eu
- run: mkdir "$HOME/.ssh"
- run: echo "${{ secrets.DEV_KEY }}" > "$HOME/.ssh/DEV_KEY"
- run: chmod 600 "$HOME/.ssh/DEV_KEY"
# Deploy bild
- run: rsync -e "ssh -i $HOME/.ssh/DEV_KEY -o StrictHostKeyChecking=no" --progress --exclude={".*/","node_modules","src"} --archive --compress --delete . [LOGIN]@[IP]:/var/www/site/
# ssh deploy & restart
- name: deploy
uses: garygrossgarten/github-action-ssh@release
with:
command: |
cd /var/www/site
npm install
pm2 restart site --update-env
host: [IP]
username: [LOGIN]
privateKey: ${{ secrets.DEV_KEY }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment