Last active
June 30, 2023 10:29
-
-
Save nrjdalal/6cc6f1990ed6bb12dff64753c6974638 to your computer and use it in GitHub Desktop.
node app github actions workflow
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
# 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