Skip to content

Instantly share code, notes, and snippets.

@sistematico
Last active December 14, 2022 09:33
Show Gist options
  • Select an option

  • Save sistematico/f93251a76b6c81f3c95afc2528b8c65e to your computer and use it in GitHub Desktop.

Select an option

Save sistematico/f93251a76b6c81f3c95afc2528b8c65e to your computer and use it in GitHub Desktop.
Node.js scaffolding

🌎 Repo Name

Repo desc...

🤖 CI/CD

CD

Ajude

Se o meu trabalho foi útil de qualquer maneira, considere doar qualquer valor através do das seguintes plataformas:

LiberaPay PagSeguro ko-fi Buy Me a Coffee Open Collective Patreon

GitHub Sponsors

name: Node.js Deploy
on:
push:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Copy repository contents via scp
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
password: ${{ secrets.SSH_PASS }}
port: ${{ secrets.SSH_PORT }}
source: "."
target: ${{ secrets.PROJECT_PATH }}
build:
needs: deploy
runs-on: ubuntu-latest
steps:
- name: Building Laravel Site
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
password: ${{ secrets.SSH_PASS }}
port: ${{ secrets.SSH_PORT }}
script: |
cd ${{ secrets.PROJECT_PATH }}
git pull origin main
[ -f .env ] || cp .env.example .env
pnpm install
pnpm install --only=prod
pm2 restart app
[Unit]
Description=Node.js App Systemd Unit
Documentation=https://example.com
After=network.target
[Service]
Environment=NODE_PORT=3000
Type=simple
User=caddy
ExecStart=/usr/bin/node /var/www/site.com/api/app.js
Restart=on-failure
[Install]
WantedBy=multi-user.target
{
"name": "appname",
"version": "1.0.0",
"description": "App description",
"main": "app.js",
"scripts": {
"start": "node app"
},
"keywords": [],
"author": "Your Name <your@email.com>",
"license": "ISC"
}
{
"npm.packageManager": "pnpm"
}
{
"version": "2.0.0",
"tasks": [
{
"label": "NPM Install",
"type": "npm",
"script": "install",
"problemMatcher": [],
"detail": "pnpm install",
"group": "none",
"presentation": {
"reveal": "always",
"panel": "new"
}
},
{
"label": "NPM Start",
"type": "npm",
"script": "start",
"problemMatcher": [],
"detail": "pnpm run start",
"group": "none",
"runOptions": {
"runOn": "folderOpen"
},
"presentation": {
"reveal": "never",
"panel": "new"
}
},
{
"label": "NPM Dev",
"type": "npm",
"script": "dev",
"problemMatcher": [],
"detail": "pnpm run dev",
"group": "none",
"presentation": {
"reveal": "never",
"panel": "new"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment