Skip to content

Commit

Permalink
Merge branch 'develop' into feature/BE/GWL-64
Browse files Browse the repository at this point in the history
  • Loading branch information
sjy982 committed Nov 20, 2023
2 parents b6a6852 + 2fc6c39 commit c6a945d
Show file tree
Hide file tree
Showing 28 changed files with 833 additions and 112 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/BackEnd_CD.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: BackEnd-CD

on:
push:
branches:
- develop
paths:
- 'BackEnd/**'

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: docker/setup-buildx-action@v2

- uses: docker/login-action@v2
with:
registry: ${{ secrets.NCP_CONTAINER_REGISTRY }}
username: ${{ secrets.NCP_ACCESS_KEY }}
password: ${{ secrets.NCP_SECRET_KEY }}

- uses: docker/build-push-action@v3
with:
context: .
file: ./BackEnd/Dockerfile
push: true
tags: ${{ secrets.NCP_CONTAINER_REGISTRY }}/my-app:latest

- name: SSH to Internal Server and Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.BASTION_HOST }}
username: ${{ secrets.BASTION_USER }}
password: ${{ secrets.BASTION_PASSWORD }}
port: 22
script: |
sshpass -p ${{ secrets.SERVER_PASSWORD }} ssh -o StrictHostKeyChecking=no ${{ secrets.SERVER_USER }}@${{ secrets.INTERNAL_SERVER_IP }} -p 22 '
docker pull ${{ secrets.NCP_CONTAINER_REGISTRY }}/my-app:latest
docker stop my-app || true
docker rm my-app || true
docker run --name my-app -d -p 443:3000 -p 80:3000 ${{ secrets.NCP_CONTAINER_REGISTRY }}/my-app:latest
docker cp /var/env/.env my-app:/app/.env
'
10 changes: 3 additions & 7 deletions .github/workflows/BackEnd_CI.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
name: BackEnd-CI

on:
push:
branches: 'feature/BE/*'
pull_request:
branches: 'develop'
types: [labeled, opened, synchronize, reopened]
types: [opened, synchronize, reopened, edited]

jobs:
test:
if: contains(github.event.pull_request.labels.*.name, '💻백엔드')
runs-on: ubuntu-latest

steps:
- name: 코드 체크아웃
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: node 세팅
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: '18'

Expand Down
17 changes: 17 additions & 0 deletions BackEnd/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 빌드 단계
FROM node:18 AS builder
WORKDIR /app
COPY BackEnd/package*.json ./
RUN npm install
COPY BackEnd/ .
RUN npm run build

# 실행 단계
FROM node:18
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/package*.json ./
RUN npm install --only=production
RUN npm install pm2 -g
EXPOSE 3000
CMD ["pm2-runtime", "start", "dist/main.js"]
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import Coordinator
import UIKit

// MARK: - AppCoordinator

final class AppCoordinator: AppCoordinating {
var navigationController: UINavigationController
var childCoordinators: [Coordinating] = []
Expand All @@ -28,11 +30,19 @@ final class AppCoordinator: AppCoordinating {
tabBarCoordinator.start()
}

func startLoginFlow() {
func showLoginFlow() {
// (LoginViewController 추가되면 로직 추가) (todo)
}

func startTabBarFlow() {
func showTabBarFlow() {
// (TabBarController 추가되면 로직 추가) (todo)
}
}

// MARK: CoordinatorFinishDelegate

extension AppCoordinator: CoordinatorFinishDelegate {
func flowDidFinished(childCoordinator: Coordinating) {
// TODO: 로그아웃 Flow, 로그인 Flow (앱 실행 도중 발생되는 분기처리)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ import Coordinator
import Foundation

protocol AppCoordinating: Coordinating {
func startLoginFlow()
func startTabBarFlow()
func showLoginFlow()
func showTabBarFlow()
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ final class TabBarCoordinator: TabBarCoordinating {
navigationController.pushViewController(tabBarController, animated: false)
}

private func makePageNavigationController(page: TabBarPage) -> UINavigationController {
let navigationController = UINavigationController()
let tabBarItem = UITabBarItem(title: page.title, image: page.image, selectedImage: page.selectedImage)
navigationController.tabBarItem = tabBarItem
startTabBarCoordinator(page: page, pageNavigationViewController: navigationController)
return navigationController
}

private func startTabBarCoordinator(page: TabBarPage, pageNavigationViewController: UINavigationController) {
switch page {
case .home:
Expand All @@ -54,14 +62,6 @@ final class TabBarCoordinator: TabBarCoordinating {
}
}

private func makePageNavigationController(page: TabBarPage) -> UINavigationController {
let navigationController = UINavigationController()
let tabBarItem = UITabBarItem(title: page.title, image: page.image, selectedImage: page.selectedImage)
navigationController.tabBarItem = tabBarItem
startTabBarCoordinator(page: page, pageNavigationViewController: navigationController)
return navigationController
}

private func makeTabBarController(
tabBarViewControllers: [UIViewController]
) -> UITabBarController {
Expand Down
2 changes: 2 additions & 0 deletions iOS/Projects/Core/Coordinator/Sources/CoordinatorFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ import Foundation
public enum CoordinatorFlow {
case login
case tabBar
case workoutSetting
case workout
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// WorkoutSettingCoordinatorFinishDelegate.swift
// RecordFeature
//
// Created by 안종표 on 2023/11/20.
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved.
//

import Foundation

protocol WorkoutSettingCoordinatorFinishDelegate: AnyObject {
func workoutSettingCoordinatorDidFinished(workoutSetting: WorkoutSetting)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// RecordFeatureCoordinating.swift
// RecordFeature
//
// Created by 안종표 on 2023/11/20.
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved.
//

import Coordinator
import Foundation

protocol RecordFeatureCoordinating: Coordinating {
func showSettingFlow()
func showWorkoutFlow(workoutSetting: WorkoutSetting)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// WorkoutCoordinating.swift
// RecordFeature
//
// Created by 안종표 on 2023/11/20.
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved.
//

import Coordinator
import Foundation

protocol WorkoutCoordinating: Coordinating {
func pushWorkoutSummaryViewController()
func pushWorkoutMapViewController()
func pushWorkoutResultViewController()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// WorkoutSettingCoordinating.swift
// RecordFeature
//
// Created by 안종표 on 2023/11/20.
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved.
//

import Coordinator
import Foundation

protocol WorkoutSettingCoordinating: Coordinating {
func pushWorkoutSelectViewController()
func pushWorkoutEnvironmentSetupViewController(workoutSetting: WorkoutSetting)
func pushOpponentSearchViewController(workoutSetting: WorkoutSetting)
func pushCountdownViewController(workoutSetting: WorkoutSetting)
func finish(workoutSetting: WorkoutSetting)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//
// RecordFeatureCoordinator.swift
// RecordFeature
//
// Created by 안종표 on 2023/11/20.
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved.
//

import Coordinator
import UIKit

// MARK: - RecordFeatureCoordinator

public final class RecordFeatureCoordinator: RecordFeatureCoordinating {
public var navigationController: UINavigationController
public var childCoordinators: [Coordinating] = []
public weak var finishDelegate: CoordinatorFinishDelegate?
public var flow: CoordinatorFlow = .workoutSetting
public var recordContainerViewController: RecordContainerViewController

public init(
navigationController: UINavigationController
) {
self.navigationController = navigationController
recordContainerViewController = RecordContainerViewController()
}

public func start() {
navigationController.pushViewController(recordContainerViewController, animated: false)
}

func showSettingFlow() {
let workoutSettingCoordinator = WorkoutSettingCoordinator(navigationController: navigationController)
childCoordinators.append(workoutSettingCoordinator)
workoutSettingCoordinator.finishDelegate = self
workoutSettingCoordinator.settingDidFinishedDelegate = self
workoutSettingCoordinator.start()
}

func showWorkoutFlow(workoutSetting _: WorkoutSetting) {
let workoutCoordinator = WorkoutCoordinator(navigationController: navigationController)
childCoordinators.append(workoutCoordinator)
workoutCoordinator.finishDelegate = self
workoutCoordinator.start()
}
}

// MARK: CoordinatorFinishDelegate

extension RecordFeatureCoordinator: CoordinatorFinishDelegate {
public func flowDidFinished(childCoordinator: Coordinating) {
childCoordinators = childCoordinators.filter {
$0.flow != childCoordinator.flow
}
navigationController.popToRootViewController(animated: false)
}
}

// MARK: WorkoutSettingCoordinatorFinishDelegate

extension RecordFeatureCoordinator: WorkoutSettingCoordinatorFinishDelegate {
func workoutSettingCoordinatorDidFinished(workoutSetting: WorkoutSetting) {
showWorkoutFlow(workoutSetting: workoutSetting)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// WorkoutCoordinator.swift
// RecordFeature
//
// Created by 안종표 on 2023/11/20.
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved.
//

import Coordinator
import UIKit

final class WorkoutCoordinator: WorkoutCoordinating {
var navigationController: UINavigationController
var childCoordinators: [Coordinating] = []
weak var finishDelegate: CoordinatorFinishDelegate?
var flow: CoordinatorFlow = .workout

init(navigationController: UINavigationController) {
self.navigationController = navigationController
}

func start() {
pushWorkoutSummaryViewController()
}

func pushWorkoutSummaryViewController() {
let workoutSummaryViewController = WorkoutSummaryViewController(
viewModel: WorkoutSummaryViewModel()
)
navigationController.pushViewController(workoutSummaryViewController, animated: false)
}

func pushWorkoutMapViewController() {
// TODO: 뷰 컨트롤러 시작 로직 작성
}

func pushWorkoutResultViewController() {
// TODO: 뷰 컨트롤러 시작 로직 작성
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// WorkoutSettingCoordinator.swift
// RecordFeature
//
// Created by 안종표 on 2023/11/20.
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved.
//

import Coordinator
import UIKit

final class WorkoutSettingCoordinator: WorkoutSettingCoordinating {
var navigationController: UINavigationController
var childCoordinators: [Coordinating] = []
weak var finishDelegate: CoordinatorFinishDelegate?
var flow: CoordinatorFlow = .workoutSetting
weak var settingDidFinishedDelegate: WorkoutSettingCoordinatorFinishDelegate?

init(navigationController: UINavigationController) {
self.navigationController = navigationController
}

func start() {
pushWorkoutSelectViewController()
}

func pushWorkoutSelectViewController() {
let workoutSelectViewController = WorkoutSelectViewController()
navigationController.pushViewController(workoutSelectViewController, animated: false)
}

func pushWorkoutEnvironmentSetupViewController(workoutSetting _: WorkoutSetting) {
// TODO: WorkoutEnvironmentSetupViewController의 Usecase에 workoutSetting 객체를 전달해줘야한다.
let workoutEnvironmentViewController = WorkoutEnvironmentSetupViewController()
navigationController.pushViewController(workoutEnvironmentViewController, animated: false)
}

func pushOpponentSearchViewController(workoutSetting _: WorkoutSetting) {
// TODO: 뷰 컨트롤러 시작 로직 작성
}

func pushCountdownViewController(workoutSetting _: WorkoutSetting) {
// TODO: 뷰 컨트롤러 시작 로직 작성
}

func finish(workoutSetting: WorkoutSetting) {
settingDidFinishedDelegate?.workoutSettingCoordinatorDidFinished(workoutSetting: workoutSetting)
}
}
Loading

0 comments on commit c6a945d

Please sign in to comment.