-
Notifications
You must be signed in to change notification settings - Fork 2
MOSU-249 feat: 배포 환경에 따른 yml 분리 #257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
cbde362
fe516dc
b9e1687
7c3b84a
546d6ce
9d6003d
6c4dcd2
8db0333
7c0d2b7
fb7a598
e5076ec
211511b
1daba52
4233ed8
795a6e9
6ea148a
9e44526
b61bb05
50cba22
553dd16
5bc6c38
6341200
921b2ef
5d7fb7b
46e7c7a
34a04b5
6bd062b
caa0723
df0354e
572ddb0
b680c70
bc7d613
40f61d0
a0a4473
c5be4ad
a0fd7db
6a43347
53b4e11
1d40637
febbe32
e784335
50915bc
24f6e2e
03357a6
affed22
7f0bf73
3dbbf21
da95311
3f0a973
08a58cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,20 +3,68 @@ name: Docker CI/CD - Deploy | |||||||||||||||||||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| workflow_dispatch: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| branches: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - test | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - develop | ||||||||||||||||||||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| deploy: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| runs-on: self-hosted | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Checkout source | ||||||||||||||||||||||||||||||||||||||||||||||||||
| uses: actions/checkout@v3 | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Set up JDK 21 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| uses: actions/setup-java@v3 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| java-version: '21' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| distribution: 'temurin' | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Cache Gradle files | ||||||||||||||||||||||||||||||||||||||||||||||||||
| uses: actions/cache@v3 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| path: | | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ~/.gradle/caches | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ~/.gradle/wrapper | ||||||||||||||||||||||||||||||||||||||||||||||||||
| key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| restore-keys: | | ||||||||||||||||||||||||||||||||||||||||||||||||||
| gradle-${{ runner.os }}- | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Clone external repo with jar into libs/ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||
| mkdir -p libs | ||||||||||||||||||||||||||||||||||||||||||||||||||
| git clone https://x-access-token:${{ secrets.GH_PAT }}@github.com/mosu-dev/mosu-kmc-jar.git temp-jar | ||||||||||||||||||||||||||||||||||||||||||||||||||
| cp temp-jar/*.jar libs/ | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Build with Gradle | ||||||||||||||||||||||||||||||||||||||||||||||||||
| run: ./gradlew build -x test | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Log in to DockerHub | ||||||||||||||||||||||||||||||||||||||||||||||||||
| uses: docker/login-action@v3 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| username: ${{ secrets.DOCKER_USERNAME }} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| password: ${{ secrets.DOCKER_PASSWORD }} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Build Docker image | ||||||||||||||||||||||||||||||||||||||||||||||||||
| run: docker build -t kangtaehyun1107/mosu-server:${{ github.sha }} . | ||||||||||||||||||||||||||||||||||||||||||||||||||
| working-directory: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Push Docker image | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+48
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix invalid empty 'working-directory' key The empty value breaks workflow parsing (“string should not be empty”). Either set it explicitly or remove it. Apply: - working-directory:
+ # working-directory: .📝 Committable suggestion
Suggested change
🧰 Tools🪛 actionlint (1.7.7)48-48: string should not be empty (syntax-check) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
| run: docker push kangtaehyun1107/mosu-server:${{ github.sha }} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Deploy via SSH | ||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||
| cd ~/mosu-server | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "${{ secrets.TEST_ENV_BLUE }}" > .env.blue | ||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "${{ secrets.TEST_ENV_GREEN }}" > .env.green | ||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "${{ secrets.ENV_BASE }}" > .env | ||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "${{ secrets.ENV_BASE }}" > .env.blue | ||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "${{ secrets.ENV_BASE }}" > .env.green | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "${{ secrets.ENV_TEST }}" >> .env | ||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "${{ secrets.ENV_TEST }}" >> .env.blue | ||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "${{ secrets.ENV_TEST }}" >> .env.green | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "APP_IMAGE_VERSION=${{ github.sha }}" >> .env | ||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "APP_IMAGE_VERSION=${{ github.sha }}" >> .env.blue | ||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "APP_IMAGE_VERSION=${{ github.sha }}" >> .env.green | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+56
to
+67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Safer multi-line secret writes and file permissions Use printf and a restrictive umask to prevent permission leaks. Also keeps newline handling deterministic. Apply: - echo "${{ secrets.ENV_BASE }}" > .env
- echo "${{ secrets.ENV_BASE }}" > .env.blue
- echo "${{ secrets.ENV_BASE }}" > .env.green
-
- echo "${{ secrets.ENV_TEST }}" >> .env
- echo "${{ secrets.ENV_TEST }}" >> .env.blue
- echo "${{ secrets.ENV_TEST }}" >> .env.green
-
- echo "APP_IMAGE_VERSION=${{ github.sha }}" >> .env
- echo "APP_IMAGE_VERSION=${{ github.sha }}" >> .env.blue
- echo "APP_IMAGE_VERSION=${{ github.sha }}" >> .env.green
+ umask 077
+ printf '%s\n' "${{ secrets.ENV_BASE }}" > .env
+ printf '%s\n' "${{ secrets.ENV_BASE }}" > .env.blue
+ printf '%s\n' "${{ secrets.ENV_BASE }}" > .env.green
+
+ printf '%s\n' "${{ secrets.ENV_TEST }}" >> .env
+ printf '%s\n' "${{ secrets.ENV_TEST }}" >> .env.blue
+ printf '%s\n' "${{ secrets.ENV_TEST }}" >> .env.green
+
+ printf '%s\n' "APP_IMAGE_VERSION=${{ github.sha }}" >> .env
+ printf '%s\n' "APP_IMAGE_VERSION=${{ github.sha }}" >> .env.blue
+ printf '%s\n' "APP_IMAGE_VERSION=${{ github.sha }}" >> .env.green📝 Committable suggestion
Suggested change
🧰 Tools🪛 YAMLlint (1.37.1)[error] 59-59: trailing spaces (trailing-spaces) [error] 63-63: trailing spaces (trailing-spaces) [error] 67-67: trailing spaces (trailing-spaces) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
| sudo docker stop $(sudo docker ps -aq) || true | ||||||||||||||||||||||||||||||||||||||||||||||||||
| sudo docker rm $(sudo docker ps -aq) || true | ||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Stopping all containers..." | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package life.mosu.mosuserver.application.caffeine; | ||
|
|
||
| import com.github.benmanes.caffeine.cache.Caffeine; | ||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import java.util.stream.Collectors; | ||
| import life.mosu.mosuserver.domain.caffeine.CacheGroup; | ||
| import life.mosu.mosuserver.domain.caffeine.CacheType; | ||
| import org.springframework.cache.Cache; | ||
| import org.springframework.cache.CacheManager; | ||
| import org.springframework.cache.annotation.EnableCaching; | ||
| import org.springframework.cache.caffeine.CaffeineCache; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.context.annotation.Primary; | ||
|
|
||
| @EnableCaching | ||
| @Configuration | ||
| public class LocalCacheConfig { | ||
|
|
||
| @Bean | ||
| public LocalCacheManager localCacheManager() { | ||
| List<Cache> caches = Arrays.stream(CacheGroup.values()) | ||
| .filter(g -> g.getCacheType() == CacheType.LOCAL | ||
| || g.getCacheType() == CacheType.COMPOSITE) | ||
| .map(g -> new CaffeineCache( | ||
| g.getCacheName(), | ||
| Caffeine.newBuilder() | ||
| .recordStats() | ||
| .expireAfterWrite(g.getExpiredAfterWrite()) | ||
| .build() | ||
| )).collect(Collectors.toList()); | ||
|
|
||
| return new LocalCacheManager(caches); | ||
| } | ||
|
|
||
| @Bean | ||
| @Primary | ||
| public CacheManager appCacheManager(LocalCacheManager localCacheManager) { | ||
| return localCacheManager; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| package life.mosu.mosuserver.application.caffeine; | ||
|
|
||
| import jakarta.annotation.Nullable; | ||
| import jakarta.annotation.PostConstruct; | ||
| import java.util.Collection; | ||
| import java.util.Collections; | ||
| import java.util.LinkedHashSet; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
| import java.util.concurrent.ConcurrentHashMap; | ||
| import org.springframework.cache.Cache; | ||
| import org.springframework.cache.CacheManager; | ||
|
|
||
| public class LocalCacheManager implements CacheManager, UpdatableCacheManager { | ||
|
|
||
| private final List<Cache> caches; | ||
| private Map<String, Cache> cacheMap = new ConcurrentHashMap<>(); | ||
| private volatile Set<String> cacheNames = Collections.emptySet(); | ||
|
|
||
| public LocalCacheManager(List<Cache> caches) { | ||
| this.caches = (caches != null) ? caches : Collections.emptyList(); | ||
| } | ||
|
|
||
| @PostConstruct | ||
| public void init() { | ||
| Set<String> cacheNamesSet = new LinkedHashSet<>(caches.size()); | ||
| Map<String, Cache> cacheMapTemp = new ConcurrentHashMap<>(16); | ||
|
|
||
| for (Cache cache : caches) { | ||
| String name = cache.getName(); | ||
| cacheNamesSet.add(name); | ||
| cacheMapTemp.put(name, cache); | ||
| } | ||
| this.cacheMap = cacheMapTemp; | ||
| this.cacheNames = cacheNamesSet; | ||
| } | ||
|
|
||
| @Override | ||
| @Nullable | ||
| public Cache getCache(String name) { | ||
| return cacheMap.get(name); | ||
| } | ||
|
|
||
| @Override | ||
| public Collection<String> getCacheNames() { | ||
| return cacheNames; | ||
| } | ||
|
|
||
| @Override | ||
| public void putIfAbsent(Cache cache, String key, Object value) { | ||
| Cache localCache = getCache(cache.getName()); | ||
| if (localCache != null) { | ||
| localCache.putIfAbsent(key, value); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package life.mosu.mosuserver.application.caffeine; | ||
|
|
||
| import org.springframework.cache.Cache; | ||
|
|
||
| public interface UpdatableCacheManager { | ||
|
|
||
| void putIfAbsent(Cache cache, String key, Object value); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update deprecated action versions (checkout/setup-java/cache)
actionlint flags these actions as too old. Upgrade to v4 for better support and security fixes.
Apply:
Also applies to: 21-30
🧰 Tools
🪛 actionlint (1.7.7)
13-13: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
16-16: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🤖 Prompt for AI Agents