Skip to content

fix: 관심과목 분석 상세 페이지 버그 수정 #189

fix: 관심과목 분석 상세 페이지 버그 수정

fix: 관심과목 분석 상세 페이지 버그 수정 #189

Workflow file for this run

name: PR Preview
on:
pull_request:
branches: [develop]
types: [opened, synchronize, reopened, closed]
jobs:
build-client:
if: github.event.action != 'closed'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
- name: Install pnpm
run: npm install -g pnpm
- name: Install dependencies
run: pnpm i --frozen-lockfile
- name: Build Client for Preview
run: pnpm -F @allcll/client run build
env:
VITE_BASE: /pr-${{ github.event.pull_request.number }}/
VITE_SUPABASE_URL: ${{ secrets.DEV_SUPABASE_URL }}
VITE_SUPABASE_ANON_KEY: ${{ secrets.DEV_SUPABASE_ANON_KEY }}
VITE_SUPABASE_TABLE_NAME: ${{ secrets.DEV_SUPABASE_TABLE_NAME }}
VITE_API_BASE_URL: ${{ secrets.DEV_API_BASE_URL }}
VITE_DEV_SERVER: true
- name: Upload Client Artifact
uses: actions/upload-artifact@v4
with:
name: client-dist
path: packages/client/dist
build-admin:
if: github.event.action != 'closed'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
- name: Install pnpm
run: npm install -g pnpm
- name: Install dependencies
run: pnpm i --frozen-lockfile
- name: Build Admin for Preview
run: pnpm -F @allcll/admin run build
env:
VITE_BASE: /pr-${{ github.event.pull_request.number }}/
VITE_SUPABASE_URL: ${{ secrets.DEV_SUPABASE_URL }}
VITE_SUPABASE_ANON_KEY: ${{ secrets.DEV_SUPABASE_ANON_KEY }}
VITE_SUPABASE_TABLE_NAME: ${{ secrets.DEV_SUPABASE_TABLE_NAME }}
VITE_API_BASE_URL: ${{ secrets.DEV_API_BASE_URL }}
VITE_DEV_SERVER: true
- name: Upload Admin Artifact
uses: actions/upload-artifact@v4
with:
name: admin-dist
path: packages/admin/dist
deploy-preview:
if: github.event.action != 'closed'
needs: [build-client, build-admin]
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Download Client Artifact
uses: actions/download-artifact@v4
with:
name: client-dist
path: client-dist
- name: Download Admin Artifact
uses: actions/download-artifact@v4
with:
name: admin-dist
path: admin-dist
- name: Deploy Client preview to server
uses: appleboy/scp-action@v1
with:
host: ${{ secrets.DEV_SERVER_HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.DEV_SERVER_SSH_KEY }}
port: 22
source: client-dist/*
target: ${{ secrets.PWD }}/clients/pr-${{ github.event.pull_request.number }}
strip_components: 1
- name: Deploy Admin preview to server
uses: appleboy/scp-action@v1
with:
host: ${{ secrets.DEV_SERVER_HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.DEV_SERVER_SSH_KEY }}
port: 22
source: admin-dist/*
target: ${{ secrets.PWD }}/admins/pr-${{ github.event.pull_request.number }}
strip_components: 1
- name: Reload Nginx
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.DEV_SERVER_HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.DEV_SERVER_SSH_KEY }}
port: 22
script: sudo systemctl reload nginx
- name: Comment preview URL on PR
uses: actions/github-script@v7
env:
CLIENT_PREVIEW_BASE_URL: ${{ secrets.DEV_CLIENT_PREVIEW_BASE_URL }}
ADMIN_PREVIEW_BASE_URL: ${{ secrets.DEV_ADMIN_PREVIEW_BASE_URL }}
with:
script: |
const pr_number = context.payload.pull_request.number;
const client_base_url = process.env.CLIENT_PREVIEW_BASE_URL || 'https://dev.allcll.kr';
const admin_base_url = process.env.ADMIN_PREVIEW_BASE_URL || 'https://dev-admin.allcll.kr';
const client_preview_url = `${client_base_url}/pr-${pr_number}/`;
const admin_preview_url = `${admin_base_url}/pr-${pr_number}/`;
const body = [
'## 🚀 Preview Deployment',
`- **Client:** ${client_preview_url}`,
`- **Admin:** ${admin_preview_url}`,
'> This preview is automatically updated on each push.',
].join('\n');
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr_number,
});
const existing = comments.find(c => c.body.includes('## 🚀 Preview Deployment'));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr_number,
body,
});
}
cleanup-preview:
if: github.event.action == 'closed' && github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
permissions: {} # No permissions needed
steps:
- name: Remove preview directories and reload Nginx
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.DEV_SERVER_HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.DEV_SERVER_SSH_KEY }}
port: 22
script: |
PR_NUMBER="${{ github.event.pull_request.number }}"
if [[ "$PR_NUMBER" =~ ^[0-9]+$ ]]; then
sudo rm -rf "${{ secrets.PWD }}/clients/pr-${PR_NUMBER}"
sudo rm -rf "${{ secrets.PWD }}/admins/pr-${PR_NUMBER}"
sudo systemctl reload nginx
fi