diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f71c79a..73bb191 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,39 +1,48 @@ +name: Trigger Web Deploy + on: - push: + push: + branches: + - master + + pull_request: branches: - master -name: Production Deployment + jobs: - deploy: - name: Deploy + trigger-deploy: runs-on: ubuntu-latest - steps: - - name: 🚚 Get latest code - uses: actions/checkout@v2 - - name: Cache node modules - uses: actions/cache@v1 - with: - path: node_modules - key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.OS }}-build- - ${{ runner.OS }}- + env: + PR_TITLE: ${{ github.event.pull_request.title || '' }} + COMMIT_MESSAGE: ${{ github.event.head_commit.message || '' }} + FINAL_TITLE: ${{ github.event.pull_request.title || github.event.head_commit.message }} - - name: 🧩 Install Modules - run: yarn + steps: + - name: Checkout Code + uses: actions/checkout@v2 - - name: πŸ‘·β€β™‚οΈ Build Project - run: yarn build - env: - CI: false + - name: Clean Commit Message + id: clean-message + run: | + CLEAN_TITLE=$(echo "${{ env.FINAL_TITLE }}" | tr -d '\000-\031') + echo "CLEAN_TITLE=$CLEAN_TITLE" >> $GITHUB_ENV - - name: πŸ“‚ Sync files - uses: SamKirkland/FTP-Deploy-Action@4.3.2 + - name: Trigger Deploy + uses: peter-evans/repository-dispatch@v2 with: - server: ${{ secrets.DODAM_FILEZILLA_IP }} - username: ${{ secrets.DODAM_FILEZILLA_USERNAME }} - password: ${{ secrets.DODAM_FILEZILLA_PWD }} - local-dir: ./build/ - port: 2021 - protocol: ftps + token: ${{ secrets.GIT_ACCESS_TOKEN }} + repository: team-b1nd/web-deploy-config + event-type: trigger-deploy + client-payload: | + { + "repo_name": "${{ github.repository }}", + "branch": "${{ github.ref }}", + "source_directory": "./build", + "project_name": "dodam", + "destination_directory": "/schedule", + "config_secret": "${{ secrets.CONFIG_JSON }}", + "title": "${{ env.CLEAN_TITLE }}", + "package_manager_config_command": "npm config set registry=https://npm.pkg.github.com/Team-B1ND && npm config set //npm.pkg.github.com/:_authToken=${{ secrets.GIT_ACCESS_TOKEN }} && npm config set //registry.npmjs.org/:_authToken=${{ secrets.GIT_ACCESS_TOKEN }}", + "package_manager": "npm" + } diff --git a/src/hooks/schedule/useHomeSidebarSchedule.ts b/src/hooks/schedule/useHomeSidebarSchedule.ts index d6f0673..003f206 100644 --- a/src/hooks/schedule/useHomeSidebarSchedule.ts +++ b/src/hooks/schedule/useHomeSidebarSchedule.ts @@ -1,5 +1,5 @@ import dayjs from "dayjs"; -import { useEffect, useState } from "react"; +import { useEffect, useState, useCallback } from "react"; import { useRecoilValue } from "recoil"; import { useGetMember } from "../../queries/member/member.query"; import { useGetSchedulesByDate } from "../../queries/schedule/schedule.query"; @@ -20,7 +20,7 @@ const useHomeSidebarSchedule = () => { { suspense: true }, ); - const loadMyGradeSchedules = () => { + const loadMyGradeSchedules = useCallback(() => { setSchedules( schedulesData?.data.filter( (schedule) => @@ -28,35 +28,38 @@ const useHomeSidebarSchedule = () => { schedule.targetGrades[0] === "전ꡐ생", )!, ); - }; + }, [schedulesData, memberData]); - const loadAllSchedules = () => { + const loadAllSchedules = useCallback(() => { setSchedules(schedulesData!.data); - }; + }, [schedulesData]); - const handleSchedules = (scope: string) => { - setSchedules([]); + const handleSchedules = useCallback( + (scope: string) => { + setSchedules([]); - switch (scope) { - case "전체 일정": - loadAllSchedules(); - break; + switch (scope) { + case "전체 일정": + loadAllSchedules(); + break; - case "λ‚΄ 일정": - loadMyGradeSchedules(); - break; + case "λ‚΄ 일정": + loadMyGradeSchedules(); + break; - default: - loadAllSchedules(); - break; - } - }; + default: + loadAllSchedules(); + break; + } + }, + [loadAllSchedules, loadMyGradeSchedules] + ); useEffect(() => { if (schedulesData?.data) { handleSchedules(classificationKeyword); } - }, [schedulesData?.data, classificationKeyword]); + }, [schedulesData?.data, classificationKeyword, handleSchedules]); return { schedules, diff --git a/src/lib/cookie/cookie.ts b/src/lib/cookie/cookie.ts index 83b87fe..07368b5 100644 --- a/src/lib/cookie/cookie.ts +++ b/src/lib/cookie/cookie.ts @@ -17,5 +17,5 @@ class Cookie { cookie.remove(key); } } - -export default new Cookie(); +const cookies = new Cookie(); +export default cookies; \ No newline at end of file diff --git a/src/lib/token/token.ts b/src/lib/token/token.ts index de2ef57..92b01ef 100644 --- a/src/lib/token/token.ts +++ b/src/lib/token/token.ts @@ -23,5 +23,5 @@ class Token { cookie.removeCookie(REFRESH_TOKEN_KEY); } } - -export default new Token(); +const token = new Token(); +export default token; diff --git a/src/repository/member/member.repository.ts b/src/repository/member/member.repository.ts index 2b9387c..5a5a74c 100644 --- a/src/repository/member/member.repository.ts +++ b/src/repository/member/member.repository.ts @@ -7,5 +7,5 @@ class MemberRepository { return data; } } - -export default new MemberRepository(); +const memberRepository = new MemberRepository(); +export default memberRepository; diff --git a/src/repository/schedule/schedule.repository.ts b/src/repository/schedule/schedule.repository.ts index cbcaf3d..01ec81a 100644 --- a/src/repository/schedule/schedule.repository.ts +++ b/src/repository/schedule/schedule.repository.ts @@ -13,5 +13,5 @@ class ScheduleRepository { return data; } } - -export default new ScheduleRepository(); +const scheduleRepository = new ScheduleRepository(); +export default scheduleRepository; diff --git a/src/repository/token/token.repository.ts b/src/repository/token/token.repository.ts index fc4d18e..d2dba52 100644 --- a/src/repository/token/token.repository.ts +++ b/src/repository/token/token.repository.ts @@ -14,5 +14,5 @@ class Token { return data; } } - -export default new Token(); +const token = new Token(); +export default token; diff --git a/src/util/transform/dataTransform.ts b/src/util/transform/dataTransform.ts index 8539c38..0da0944 100644 --- a/src/util/transform/dataTransform.ts +++ b/src/util/transform/dataTransform.ts @@ -63,5 +63,5 @@ class DataTransform { } } - -export default new DataTransform(); +const dataTransform = new DataTransform(); +export default dataTransform; diff --git a/src/util/transform/dateTransform.ts b/src/util/transform/dateTransform.ts index 96d5a20..673de22 100644 --- a/src/util/transform/dateTransform.ts +++ b/src/util/transform/dateTransform.ts @@ -17,5 +17,5 @@ class DateTransform { return dayjs(date).format("YYYY-MM-DD HH:mm"); } } - -export default new DateTransform(); +const dateTransform = new DateTransform(); +export default dateTransform;