Skip to content

Instantly share code, notes, and snippets.

@nrjdalal
Last active June 30, 2023 10:29
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 nrjdalal/6cc6f1990ed6bb12dff64753c6974638 to your computer and use it in GitHub Desktop.
Save nrjdalal/6cc6f1990ed6bb12dff64753c6974638 to your computer and use it in GitHub Desktop.
node app github actions workflow
# pre-requisites -> gh, yarn, pm2
name: production
on:
push:
branches: ['main', 'master']
pull_request:
branches: ['main', 'master']
jobs:
deploy:
runs-on: self-hosted
env:
username: ${{ github.event.repository.owner.login }}
reponame: ${{ github.event.repository.name }}
prodname: ${{ github.event.repository.name }}-production
defaults:
run:
working-directory: /srv
steps:
- run: rm -rf $reponame
- run: gh repo clone $username/$reponame
- run: cd $reponame && rm -rf .git && yarn
- run: rsync -r --delete $reponame/ $prodname && rm -rf $reponame
- run: if [[ $(pm2 pid $reponame) == "" ]]; then cd $prodname; pm2 start index.js --watch -n $reponame; fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment