From 03c9e086927c78b88cc18ac2fc31ed8753270359 Mon Sep 17 00:00:00 2001 From: kanguk Date: Fri, 25 Oct 2024 02:12:34 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=ED=99=98=EA=B2=BD=EB=B3=80?= =?UTF-8?q?=EC=88=98=20=EA=B4=80=EB=A6=AC=EA=B0=80=20=EC=9A=A9=EC=9D=B4?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit secret에 env.properties를 통째로 등록하여 관리할 수 있도록 한다. --- .github/workflows/cd.yml | 4 ---- .github/workflows/ci.yml | 39 ++++++++------------------------------- 2 files changed, 8 insertions(+), 35 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 2d024340..a3669a45 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -1,10 +1,6 @@ name: CD Pipeline on: - push: - branches: - - develop # develop 브랜치에 merge될 때 트리거 - - 'weekly/**' pull_request: branches: - develop diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f599e97..1dda4c56 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 @@ -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 }}