Skip to content

[REFACTOR] API 중복 호출 방지 & 중복 투표 오류 해결 #176

[REFACTOR] API 중복 호출 방지 & 중복 투표 오류 해결

[REFACTOR] API 중복 호출 방지 & 중복 투표 오류 해결 #176

Workflow file for this run

name: FE CD storybook
on:
pull_request:
branches:
- develop
paths:
- "frontend/**"
jobs:
build-and-deploy:
defaults:
run:
working-directory: frontend
runs-on: ubuntu-latest
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: frontend/package-lock.json
- name: Install Dependencies
run: npm install
- name: Cache node_modules
id: cache
uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: generate environment variables
run: |
echo "API_BASE_URL=$API_BASE_URL" >> .env
env:
API_BASE_URL: ${{ secrets.API_BASE_URL }}
- name: build storybook
run: npm run build:storybook
- name: upload storybook
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.TOKEN }}
publish_dir: ./frontend/storybook-static
destination_dir: storybook
- name: add storybook url in PR description
uses: actions/github-script@v7
with:
github-token: ${{ secrets.TOKEN }}
script: |
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
const body = pr.data.body;
const storybookUrl = "## 🌸 Storybook 배포 주소 \n\n> https://woowacourse-teams.github.io/2024-ddangkong/storybook/";
if (body.includes(storybookUrl)) {
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
body: body
});
} else {
const newBody = body + "\n\n" + storybookUrl;
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
body: newBody
});
}