Skip to content

Commit

Permalink
refactor: 환경변수 관리가 용이하도록 수정
Browse files Browse the repository at this point in the history
secret에 env.properties를 통째로 등록하여 관리할 수 있도록 한다.
  • Loading branch information
kanguk01 committed Oct 24, 2024
1 parent 42a9061 commit 03c9e08
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 35 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: CD Pipeline

on:
push:
branches:
- develop # develop 브랜치에 merge될 때 트리거
- 'weekly/**'
pull_request:
branches:
- develop
Expand Down
39 changes: 8 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ jobs:
build-and-test:
runs-on: ubuntu-22.04

env:
MYSQL_DATABASE: ${{ secrets.MYSQL_DATABASE }}
MYSQL_USER: ${{ secrets.MYSQL_USER }}
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
MYSQL_ROOT_PASSWORD: ${{ secrets.MYSQL_ROOT_PASSWORD }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}

services:
mysql:
image: mysql:8.0
Expand Down Expand Up @@ -60,17 +51,15 @@ jobs:
restore-keys: |
gradle-${{ runner.os }}-
- name: Create env.properties
- name: Decode env.properties from GitHub Secrets
run: |
echo "${{ secrets.ENV_FILE }}" | base64 --decode > ./src/main/resources/env.properties
- name: Set environment variables from env.properties
run: |
echo "MYSQL_DATABASE=${{ secrets.MYSQL_DATABASE }}" >> env.properties
echo "MYSQL_USER=${{ secrets.MYSQL_USER }}" >> env.properties
echo "MYSQL_PASSWORD=${{ secrets.MYSQL_PASSWORD }}" >> env.properties
echo "MYSQL_ROOT_PASSWORD: ${{ secrets.MYSQL_ROOT_PASSWORD }}" >> env.properties
echo "CLIENT_ID=${{ secrets.CLIENT_ID }}" >> env.properties
echo "CLIENT_SECRET=${{ secrets.CLIENT_SECRET }}" >> env.properties
echo "JWT_SECRET=${{ secrets.JWT_SECRET }}" >> env.properties
echo "REDIRECT_URL=${{ secrets.REDIRECT_URL }}" >> env.properties
cp env.properties ./src/main/resources
set -o allexport
source ./src/main/resources/env.properties
set +o allexport
- name: Set up JDK 21
uses: actions/setup-java@v2
Expand All @@ -93,25 +82,13 @@ jobs:
docker logs $(docker ps -q --filter name=mysql)
exit 1
fi
env:
MYSQL_USER: ${{ secrets.MYSQL_USER }}
MYSQL_DATABASE: ${{ secrets.MYSQL_DATABASE }}
- name: Build with Gradle
run: ./gradlew build
env:
SPRING_PROFILES_ACTIVE: local
MYSQL_DATABASE: ${{ secrets.MYSQL_DATABASE }}
MYSQL_USER: ${{ secrets.MYSQL_USER }}
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}

- name: Run Tests
run: ./gradlew test
env:
SPRING_PROFILES_ACTIVE: local
MYSQL_DATABASE: ${{ secrets.MYSQL_DATABASE }}
MYSQL_USER: ${{ secrets.MYSQL_USER }}
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}

0 comments on commit 03c9e08

Please sign in to comment.