-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b895445
commit 3e6f1ab
Showing
2 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: Nest.js with PM2 Deployment | ||
|
||
on: | ||
push: | ||
branches: ["dev-be"] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "21.7.3" | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8 | ||
run_install: false | ||
|
||
- name: Get pnpm store directory | ||
shell: bash | ||
run: | | ||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | ||
- name: Setup pnpm cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ env.STORE_PATH }} | ||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store- | ||
- name: Import environment variables | ||
run: | | ||
cd ./src | ||
echo "${{ secrets.ENV_PRODUCTION }}" > .env | ||
shell: bash | ||
|
||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Build application | ||
run: pnpm build | ||
|
||
- name: Setup SSH | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
|
||
- name: Add remote server to known hosts | ||
run: | | ||
mkdir -p ~/.ssh | ||
ssh-keyscan ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts | ||
- name: Transfer built files via SCP | ||
run: | | ||
cd dist | ||
zip -r ../dist.zip . | ||
cd .. | ||
scp -P ${{ secrets.SERVER_PORT }} ./dist.zip ${{ secrets.SSH_USER }}@${{ secrets.SERVER_IP }}:/home/${{ secrets.SSH_USER }}/deploy/clovapatra/dist.zip | ||
- name: Execute remote commands | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.SERVER_IP }} | ||
username: ${{ secrets.SSH_USER }} | ||
key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
port: ${{ secrets.SERVER_PORT }} | ||
script: | | ||
cd ~/deploy/clovapatra/ | ||
unzip -o dist.zip -d ./dist/ | ||
pm2 delete clovapatra || true | ||
pm2 start dist/main.js --name clovapatra | ||
rm dist.zip |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: React.js Deployment | ||
|
||
on: | ||
push: | ||
branches: ["dev-fe"] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-node- | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 21.7.3 | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Build | ||
run: npm run build | ||
|
||
- name: Setup SSH | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
|
||
- name: Add remote server to known hosts | ||
run: | | ||
mkdir -p ~/.ssh | ||
ssh-keyscan ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts | ||
- name: Execute remote commands | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.SERVER_IP }} | ||
username: ${{ secrets.SSH_USER }} | ||
key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
port: ${{ secrets.SERVER_PORT }} | ||
script: | | ||
sudo rm -rf /var/www/clovapatra.com/html | ||
sudo mkdir -p /var/www/clovapatra.com/html | ||
sudo chown -R ${{ secrets.SSH_USER }}:${{ secrets.SSH_USER }} /var/www/clovapatra.com/html | ||
- name: Transfer built files via rsync | ||
run: rsync -avz -e 'ssh -p ${{ secrets.SERVER_PORT }}' ./dist/ ${{ secrets.SSH_USER }}@${{ secrets.SERVER_IP }}:/var/www/clovapatra.com/html |