Skip to content

Commit

Permalink
chore: 별도의 job workflows 생성 - test, e2e, deploy-vercel
Browse files Browse the repository at this point in the history
  • Loading branch information
agaxe committed Sep 30, 2024
1 parent 37443d1 commit 58e6463
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/jobs/deploy-vercel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Deploy to Vercel
on:
workflow_call:
jobs:
deploy-vercel:
runs-on: ubuntu-latest
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install Vercel CLI
run: npm install --global vercel@latest

- name: Pull Vercel Environment Information
run: |
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }};
else
vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }};
fi
- name: Build Project Artifacts
run: |
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
vercel build --prod --token=${{ secrets.VERCEL_TOKEN }};
else
vercel build --token=${{ secrets.VERCEL_TOKEN }};
fi
- name: Deploy Project Artifacts to Vercel
run: |
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }};
else
vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }};
fi
67 changes: 67 additions & 0 deletions .github/workflows/jobs/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: End to End Test
on:
workflow_call:
inputs:
node-version:
type: number
required: false
default: 20
env:
type: choice
required: true
options:
- dev
- prod
jobs:
e2e:
runs-on: ubuntu-latest
env:
APP_ENV: ${{ inputs.env }}
NOTION_ROOT_PAGE_ID: ${{ secrets.NOTION_ROOT_PAGE_ID }}
NOTION_ACTIVE_USER_ID: ${{ secrets.NOTION_ACTIVE_USER_ID }}
NOTION_AUTH_TOKEN: ${{ secrets.NOTION_AUTH_TOKEN }}
NOTION_API_TOKEN: ${{ secrets.NOTION_API_TOKEN }}
NOTION_DB_ID: ${{ secrets.NOTION_DB_ID }}
NOTION_PORTFOLIO_PAGE_ID: ${{ secrets.NOTION_PORTFOLIO_PAGE_ID }}
BLOG_ODR_TOKEN: ${{ secrets.BLOG_ODR_TOKEN }}
NEXT_PUBLIC_GA_ID: ${{ secrets.NEXT_PUBLIC_GA_ID }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: 'yarn'

- name: Cache dependencies
id: dependencies-cache
uses: actions/cache@v3
with:
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
path: '**/node_modules'
restore-keys: |
${{ runner.os }}-node-
- name: Install Packages
if: steps.dependencies-cache.outputs.cache-hit != 'true'
run: yarn install

- name: Build project
run: yarn build

- name: Install Playwright Browsers
run: npx playwright install --with-deps

- name: Start e2e test
run: |
echo "APP_ENV is ${{ env.APP_ENV }}"
yarn e2e
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30
36 changes: 36 additions & 0 deletions .github/workflows/jobs/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Unit and Integration Tests
on:
workflow_call:
inputs:
node-version:
required: false
type: number
default: 20
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: 'yarn'

- name: Cache dependencies
id: dependencies-cache
uses: actions/cache@v3
with:
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
path: '**/node_modules'
restore-keys: |
${{ runner.os }}-node-
- name: Install Packages
if: steps.dependencies-cache.outputs.cache-hit != 'true'
run: yarn install

- name: Run Unit and Integration Tests
run: yarn run test

0 comments on commit 58e6463

Please sign in to comment.