-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
127 changed files
with
2,791 additions
and
317 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: Server CD | ||
|
||
on: | ||
pull_request: | ||
branches: [ "develop", "main" ] | ||
paths: | ||
- "server/**" | ||
types: | ||
- closed | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-20.04 | ||
|
||
strategy: | ||
matrix: | ||
node-version: [20.x] | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'npm' | ||
cache-dependency-path: '**/package-lock.json' | ||
|
||
- name: Install depenencies | ||
run: | | ||
cd server | ||
npm install | ||
- name: Create prod.env file | ||
env: | ||
DB_HOST_IP: ${{ secrets.SERVER_ENV_DB_HOST_IP }} | ||
DB_PORT: ${{ secrets.SERVER_ENV_DB_PORT }} | ||
DB_USER_NAME: ${{ secrets.SERVER_ENV_DB_USER_NAME }} | ||
DB_PASSWORD: ${{ secrets.SERVER_ENV_DB_PASSWORD }} | ||
DB_DATABASE_NAME: ${{ secrets.SERVER_ENV_DB_DATABASE_NAME }} | ||
ACCESS_ID: ${{ secrets.SERVER_ENV_ACCESS_ID }} | ||
SECRET_ACCESS_KEY: ${{ secrets.SERVER_ENV_SECRET_ACCESS_KEY }} | ||
JWT_SECRET_KEY: ${{ secrets.SERVER_ENV_JWT_SECRET_KEY }} | ||
run: | | ||
cd server | ||
touch prod.env | ||
echo "DB_HOST_IP=$DB_HOST_IP" >> prod.env | ||
echo "DB_PORT=$DB_PORT" >> prod.env | ||
echo "DB_USER_NAME=$DB_USER_NAME" >> prod.env | ||
echo "DB_PASSWORD=$DB_PASSWORD" >> prod.env | ||
echo "DB_DATABASE_NAME=$DB_DATABASE_NAME" >> prod.env | ||
echo "ACCESS_ID=$ACCESS_ID" >> prod.env | ||
echo "SECRET_ACCESS_KEY=$SECRET_ACCESS_KEY" >> prod.env | ||
echo "JWT_SECRET_KEY=$JWT_SECRET_KEY" >> prod.env | ||
- name: Build Docker image | ||
run: docker build --platform linux/amd64 ./server -t ${{ secrets.NCP_REGISTRY }}/catchy-tape:latest | ||
|
||
- name: Login NCP container registry | ||
run: docker login ${{ secrets.NCP_REGISTRY }} -u ${{ secrets.NCP_DOCKER_ACCESS_KEY_ID }} -p ${{ secrets.NCP_DOCKER_SECRET_KEY }} | ||
|
||
- name: Push Docker image to registry | ||
run: docker push ${{ secrets.NCP_REGISTRY }}/catchy-tape:latest | ||
|
||
- name: SSH into Server | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.SERVER_SSH_HOST }} | ||
username: ${{ secrets.SERVER_SSH_USER }} | ||
password: ${{ secrets.SERVER_SSH_PASSWORD }} | ||
port: ${{ secrets.SERVER_SSH_PORT }} | ||
script: | | ||
docker login ${{ secrets.NCP_REGISTRY }} -u ${{ secrets.NCP_DOCKER_ACCESS_KEY_ID }} -p ${{ secrets.NCP_DOCKER_SECRET_KEY }} | ||
docker pull ${{ secrets.NCP_REGISTRY }}/catchy-tape:latest | ||
docker stop catchy-tape-latest | ||
docker rm catchy-tape-latest | ||
docker run -d -p 3000:3000 --name catchy-tape-latest ${{ secrets.NCP_REGISTRY }}/catchy-tape:latest | ||
curl -X POST -H 'Content-type: application/json' --data '{"text":"서버 배포 성공!"}' ${{ secrets.SLACK_WEBHOOK_URL }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Backend Dev CI | ||
|
||
on: | ||
pull_request: | ||
branches: [develop] | ||
paths: | ||
- "server/**" | ||
|
||
defaults: | ||
run: | ||
working-directory: ./server | ||
|
||
jobs: | ||
BACKEND-CI: | ||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use NodeJS | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 20.8.1 | ||
|
||
- name: Cache node modules | ||
id: cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: "**/node_modules" | ||
key: npm-packages-${{ hashFiles('**/package-lock.json') }} | ||
|
||
- name: Install Dependency | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: npm install | ||
|
||
- name: Execute Test | ||
run: npm run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 22 additions & 6 deletions
28
android/app/src/main/java/com/ohdodok/catchytape/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,35 @@ | ||
package com.ohdodok.catchytape | ||
|
||
import android.content.Intent | ||
import androidx.appcompat.app.AppCompatActivity | ||
import android.net.ConnectivityManager | ||
import android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED | ||
import android.os.Bundle | ||
import com.ohdodok.catchytape.feature.login.LoginActivity | ||
import android.widget.Toast | ||
import androidx.appcompat.app.AppCompatActivity | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import com.ohdodok.catchytape.core.ui.R.string as uiString | ||
|
||
@AndroidEntryPoint | ||
class MainActivity : AppCompatActivity() { | ||
private lateinit var connectivityManager: ConnectivityManager | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
|
||
// TODO : 자동로그인 할 때 수정 필요 | ||
val intent = Intent(this, LoginActivity::class.java) | ||
startActivity(intent) | ||
connectivityManager = getSystemService(ConnectivityManager::class.java) | ||
checkNetworkState() | ||
|
||
val networkStateObserver = NetworkStateObserver(connectivityManager, ::checkNetworkState) | ||
lifecycle.addObserver(networkStateObserver) | ||
} | ||
|
||
private fun checkNetworkState() { | ||
val activeNetwork = connectivityManager.activeNetwork | ||
val capabilities = connectivityManager.getNetworkCapabilities(activeNetwork) | ||
val isNetworkAvailable = capabilities?.hasCapability(NET_CAPABILITY_VALIDATED) ?: false | ||
|
||
if (!isNetworkAvailable) { | ||
Toast.makeText(this, getString(uiString.check_network), Toast.LENGTH_LONG).show() | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
android/app/src/main/java/com/ohdodok/catchytape/NetworkStateObserver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.ohdodok.catchytape | ||
|
||
import android.net.ConnectivityManager | ||
import android.net.Network | ||
import androidx.lifecycle.DefaultLifecycleObserver | ||
import androidx.lifecycle.LifecycleOwner | ||
|
||
class NetworkStateObserver( | ||
private val connectivityManager: ConnectivityManager, | ||
checkNetworkState: () -> Unit | ||
) : DefaultLifecycleObserver { | ||
|
||
private val networkCallback = object : ConnectivityManager.NetworkCallback() { | ||
override fun onLost(network: Network) { | ||
super.onLost(network) | ||
checkNetworkState() | ||
} | ||
} | ||
|
||
override fun onResume(owner: LifecycleOwner) { | ||
super.onResume(owner) | ||
connectivityManager.registerDefaultNetworkCallback(networkCallback) | ||
} | ||
|
||
override fun onPause(owner: LifecycleOwner) { | ||
super.onPause(owner) | ||
connectivityManager.unregisterNetworkCallback(networkCallback) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<resources> | ||
<string name="app_name">Catchy Tape</string> | ||
<string name="timber_log_format">C: %s, L: %s</string> | ||
<string name="timber_blank_string">"BLANK("")"</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
android/core/data/src/main/java/com/ohdodok/catchytape/core/data/api/MusicApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.ohdodok.catchytape.core.data.api | ||
|
||
import com.ohdodok.catchytape.core.data.model.MusicGenresResponse | ||
import com.ohdodok.catchytape.core.data.model.MusicRequest | ||
import com.ohdodok.catchytape.core.data.model.MusicResponse | ||
import retrofit2.Response | ||
import retrofit2.http.Body | ||
import retrofit2.http.GET | ||
import retrofit2.http.POST | ||
|
||
interface MusicApi { | ||
|
||
@GET("musics/genres") | ||
suspend fun getGenres(): Response<MusicGenresResponse> | ||
|
||
@POST("musics") | ||
suspend fun postMusic( | ||
@Body music: MusicRequest | ||
): Response<Unit> | ||
|
||
@GET("musics/recent-uploads") | ||
suspend fun getRecentUploads(): Response<List<MusicResponse>> | ||
|
||
} |
Oops, something went wrong.