-
-
Save mskian/073ee0bd40b50a5bd06ccb4232bdb3d5 to your computer and use it in GitHub Desktop.
On New Tag create, copy the source to the server, build and restart pm2 service
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: Deploy Next.js Site via SSH | |
on: | |
push: | |
tags: | |
- "*" | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Install Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: "18.x" | |
- name: Install dependencies | |
run: npm install | |
- name: Copy files to server | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
password: ${{ secrets.SSH_PASSWORD }} | |
source: . | |
target: /var/www/your-website/ | |
- name: Connect to server and build site | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
password: ${{ secrets.SSH_PASSWORD }} | |
script: | | |
cd /var/www/your-website/ | |
yarn install | |
yarn build | |
pm2 restart 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment