Skip to content

docs: 환경변수 수정 최종 #45

docs: 환경변수 수정 최종

docs: 환경변수 수정 최종 #45

Workflow file for this run

name: Java CI with Gradle
on:
push:
branches: [ "dev" ]
pull_request:
branches: [ "dev" ]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Test env
if: env.ACTIVE_PROFILE == 'dev'
run: echo "ACTIVE PROFILE is dev"
env:
ACTIVE_PROFILE: ${{ secrets.ACTIVE_PROFILE }}
- name: Setup Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Build with Gradle Wrapper
run: ./gradlew build
env:
ACTIVE_PROFILE: ${{ secrets.ACTIVE_PROFILE }}
DATASOURCE_URL_DEV: ${{ secrets.DATASOURCE_URL_DEV }}
DATASOURCE_USERNAME: ${{ secrets.DATASOURCE_USERNAME }}
DATASOURCE_PASSWORD: ${{ secrets.DATASOURCE_PASSWORD }}
ACCESSTOKEN_EXPIREDDATE: ${{ secrets.ACCESSTOKEN_EXPIREDDATE }}
JWT_EXPIRED_IN: ${{ secrets.JWT_EXPIRED_IN }}
JWT_SECRET_KEY: ${{ secrets.JWT_SECRET_KEY }}
DATA_REDIS_HOST: ${{ secrets.DATA_REDIS_HOST }}
DATA_REDIS_PORT: ${{ secrets.DATA_REDIS_PORT }}
OAUTH_APPLE_CLIENT_ID: ${{ secrets.OAUTH_APPLE_CLIENT_ID }}
OAUTH_APPLE_NONCE: ${{ secrets.OAUTH_APPLE_NONCE }}
OAUTH_KAKAO_CLIENT_ID: ${{ secrets.OAUTH_KAKAO_CLIENT_ID }}
AWS_S3_BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME }}
AWS_S3_ACCESS_KEY: ${{ secrets.AWS_S3_ACCESS_KEY }}
AWS_S3_SECRET_KEY: ${{ secrets.AWS_S3_SECRET_KEY }}
USER_DEFAULTIMAGE: ${{ secrets.USER_DEFAULTIMAGE }}
- name: Docker build
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build --build-arg ACTIVE_PROFILE=${{ secrets.ACTIVE_PROFILE }} \
--build-arg DATASOURCE_URL_DEV=${{ secrets.DATASOURCE_URL_DEV }} \
--build-arg DATASOURCE_USERNAME=${{ secrets.DATASOURCE_USERNAME }} \
--build-arg DATASOURCE_PASSWORD=${{ secrets.DATASOURCE_PASSWORD }} \
--build-arg ACCESSTOKEN_EXPIREDDATE=${{ secrets.ACCESSTOKEN_EXPIREDDATE }} \
--build-arg JWT_EXPIRED_IN=${{ secrets.JWT_EXPIRED_IN }} \
--build-arg JWT_SECRET_KEY=${{ secrets.JWT_SECRET_KEY }} \
--build-arg DATA_REDIS_HOST=${{ secrets.DATA_REDIS_HOST }} \
--build-arg DATA_REDIS_PORT=${{ secrets.DATA_REDIS_PORT }} \
--build-arg OAUTH_APPLE_CLIENT_ID=${{ secrets.OAUTH_APPLE_CLIENT_ID }} \
--build-arg OAUTH_APPLE_NONCE=${{ secrets.OAUTH_APPLE_NONCE }} \
--build-arg OAUTH_KAKAO_CLIENT_ID=${{ secrets.OAUTH_KAKAO_CLIENT_ID }} \
--build-arg AWS_S3_BUCKET_NAME=${{ secrets.AWS_S3_BUCKET_NAME }} \
--build-arg AWS_S3_ACCESS_KEY=${{ secrets.AWS_S3_ACCESS_KEY }} \
--build-arg AWS_S3_SECRET_KEY=${{ secrets.AWS_S3_SECRET_KEY }} \
--build-arg USER_DEFAULTIMAGE=${{ secrets.USER_DEFAULTIMAGE }} \
-t app .
docker tag app ${{ secrets.DOCKER_USERNAME }}/conet:latest
docker push ${{ secrets.DOCKER_USERNAME }}/conet:latest
- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }} # EC2 인스턴스 퍼블릭 DNS
port: 22
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }} # pem 키
# 도커 작업
script: |
docker pull ${{ secrets.DOCKER_USERNAME }}/conet:latest
docker stop $(docker ps -a -q)
docker run -d --log-driver=syslog -p 9001:9000 ${{ secrets.DOCKER_USERNAME }}/conet:latest
docker rm $(docker ps --filter 'status=exited' -a -q)
docker image prune -a -f