Skip to content

Feature#84: DangerJS 초기설정 및 CI 파이프라인 통합 #48

Feature#84: DangerJS 초기설정 및 CI 파이프라인 통합

Feature#84: DangerJS 초기설정 및 CI 파이프라인 통합 #48

Workflow file for this run

name: Run Tests
on:
workflow_dispatch:
pull_request:
branches: ["main", "develop"]
types: [opened, reopened, synchronize]
jobs:
cache:
name: Cache Node Modules
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Cache node_modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
danger:
name: Run DangerJS
runs-on: ubuntu-latest
needs: cache
permissions:
issues: write
pull-requests: write
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Cache node_modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Yarn Package Manager
run: npm install -g yarn
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run DangerJS
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx danger ci
unit-test:
name: Unit Test
runs-on: ubuntu-latest
needs: danger
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Cache node_modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Yarn Package Manager
run: npm install -g yarn
- name: Install dependencies
run: yarn install
- name: Run tests
run: yarn test
ui-test:
name: Storybook UI Test
runs-on: ubuntu-latest
needs: unit-test
permissions:
issues: write
pull-requests: write
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Cache node_modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Yarn Package Manager
run: npm install -g yarn
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build Storybook
run: yarn build-storybook
- name: Create Preview
id: chromatic
uses: chromaui/action@latest
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
onlyChanged: true
autoAcceptChanges: false
exitOnceUploaded: true
- name: Comment Storybook and Chromatic URLs on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const storybookUrl = '${{ steps.chromatic.outputs.url }}';
const chromaticBuildUrl = '${{ steps.chromatic.outputs.buildUrl }}';
const prNumber = context.payload.pull_request.number;
let commentBody = '';
if (!storybookUrl) console.warn('Storybook URL not found.');
else commentBody += `📖 **Storybook Preview:** ${storybookUrl}\n`;
if (!chromaticBuildUrl) console.warn('Chromatic Build URL not found.');
else commentBody += `🔍 **Chromatic Review:** ${chromaticBuildUrl}\n`;
if (!commentBody) console.warn('No URLs available to comment.');
else {
await github.rest.issues.createComment({
...context.repo,
issue_number: prNumber,
body: commentBody,
});
console.log('Storybook and Chromatic URLs commented on PR.');
}