Skip to content

Commit

Permalink
์ถ”๊ฐ€: firebase key again
Browse files Browse the repository at this point in the history
  • Loading branch information
rrosiee committed Jun 1, 2024
1 parent 8a165ff commit 78c5fae
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ jobs:
java-version: '11'
distribution: "adopt"

- name: create firebase key
run: |
cd ./src/main/resources
ls -a .
touch ./firebase-service-key.json
echo "${{ secrets.FIREBASE_KEY }}" > ./firebase-service-key.json
shell: bash

- name: Build with Gradle
run: |
chmod +x ./gradlew
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ COPY ${JAR_FILE} app.jar

# firebase-service-key.json ํŒŒ์ผ์„ ์ปจํ…Œ์ด๋„ˆ๋กœ ๋ณต์‚ฌ
COPY src/main/resources/firebase-service-key.json /app/resources/firebase-service-key.json
COPY src/main/resources/firebase-service-key.json /app/src/main/resources/firebase-service-key.json

# ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์‹คํ–‰
ENTRYPOINT ["java", "-jar", "/app.jar"]
11 changes: 4 additions & 7 deletions src/main/java/project/backend/global/config/FirebaseConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,18 @@
import com.google.firebase.FirebaseOptions;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

@Configuration
public class FirebaseConfig {

@Bean
public FirebaseApp initializeFirebaseApp() throws IOException {
String firebaseConfig = System.getenv("FCM_SECRET");
if (firebaseConfig == null) {
throw new IOException("FCM_SECRET environment variable is not set.");
}

ByteArrayInputStream serviceAccount = new ByteArrayInputStream(firebaseConfig.getBytes());
ClassPathResource resource = new ClassPathResource("firebase-service-key.json");
InputStream serviceAccount = resource.getInputStream();

FirebaseOptions options = new FirebaseOptions.Builder()
.setCredentials(GoogleCredentials.fromStream(serviceAccount))
Expand Down

0 comments on commit 78c5fae

Please sign in to comment.