Skip to content

build[@app/punk-record]: 리빌드 #48

build[@app/punk-record]: 리빌드

build[@app/punk-record]: 리빌드 #48

Workflow file for this run

name: ci
on:
push:
branches: [main]
env:
NODE_VERSION: '20.12.1'
PNPM_VERSION: '8.15.6'
jobs:
build_packages:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install PNPM
run: npm install -g pnpm@${{ env.PNPM_VERSION }}
- name: Cache PNPM Store
id: pnpm-cache
uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build packages
run: pnpm run build --filter @repo/**
build-punk-repo:
runs-on: ubuntu-latest
needs: build_packages
if: contains(github.event.head_commit.message, '@app/punk-record')
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies.
run: |
pwd
touch .env
echo BACK_SERVER_BASE_URL=${{ secrets.BACK_SERVER_BASE_URL }} >> .env
echo FRONT_SERVER_BASE_URL=${{ secrets.FRONT_SERVER_BASE_URL }} >> .env
echo PORT=${{ secrets.PORT }} >> .env
cat .env
- name: Install PNPM
run: npm install -g pnpm@${{ env.PNPM_VERSION }}
- name: Install dependencies
run: pnpm install
- name: Build Punk Record App
run: pnpm run build --filter @app/punk-record
- name: Compress the built code.
run: zip -r build.zip ./*.json ./*.yaml ./.nvmrc ./apps/punk-record/.next ./apps/punk-record/public ./apps/punk-record/*.json ./apps/punk-record/*.yaml ./apps/punk-record/ecosystem.config.js
- name: Install sshpass
run: |
sudo apt-get update
sudo apt-get install -y sshpass
- name: Copy files to the personal server via SCP.
env:
SSHPASS: ${{ secrets.SERVER_PASSWORD }}
run: |
sshpass -e scp -o StrictHostKeyChecking=no build.zip ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_IP }}:${{ secrets.DEPLOY_PATH }}
- name: Deploy on the server.
env:
SSHPASS: ${{ secrets.SERVER_PASSWORD }}
run: |
sshpass -e ssh -o StrictHostKeyChecking=no ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_IP }} <<'ENDSSH'
echo "START DEPLOY"
cd ${{ secrets.DEPLOY_PATH }}
source ~/.bashrc
echo "Removing old build"
rm -rf ./.next
echo "Unzipping build.zip"
unzip -o build.zip
echo "Unzip completed"
echo "Fetch latest changes from git"
git fetch origin main
git reset --hard origin/main
echo "Using nvm"
nvm use
echo "Update dependencies"
pnpm install --frozen-lockfile
echo "Restarting pm2"
pm2 start ./apps/punk-record/ecosystem.config.js
echo "Deployment completed"
ENDSSH