diff --git a/.ebextensions_dev/00-makeFiles.config b/.ebextensions_dev/00-makeFiles.config new file mode 100644 index 0000000..890fa6e --- /dev/null +++ b/.ebextensions_dev/00-makeFiles.config @@ -0,0 +1,12 @@ +files: + "/sbin/appstart": + mode: "000755" + owner: webapp + group: webapp + content: | + #!/usr/bin/env bash + JAR_PATH=/var/app/current/application.jar + + # run app + killall java + java -Dfile.encoding=UTF-8 -Dspring.profiles.active=dev -jar $JAR_PATH diff --git a/.ebextensions_dev/01-set-timezone.config b/.ebextensions_dev/01-set-timezone.config new file mode 100644 index 0000000..9eb3596 --- /dev/null +++ b/.ebextensions_dev/01-set-timezone.config @@ -0,0 +1,3 @@ +commands: + set_time_zone: + command: ln -f -s /usr/share/zoneinfo/Asia/Seoul /etc/localtime diff --git a/.github/workflows/dev_deploy.yml b/.github/workflows/dev_deploy.yml new file mode 100644 index 0000000..2082bc8 --- /dev/null +++ b/.github/workflows/dev_deploy.yml @@ -0,0 +1,85 @@ +name: suppin dev CI/CD # Workflow 이름 + +on: + pull_request: + branches: + - dev + types: + - closed + workflow_dispatch: # 수동 실행도 가능하도록 + +jobs: + build: + runs-on: ubuntu-latest # OS 환경 세팅 + if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'dev' # PR이 Merge되고, base branch가 dev일 때만 실행 + + steps: + - name: Checkout + uses: actions/checkout@v2 # .github 디렉토리 하위 계층의 모든 코드 확인 + + # java 설치 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'adopt' + java-version: '17' + + # aws 환경변수 설정 + - name: Set Environment + uses: microsoft/variable-substitution@v1 + with: + files: ./src/main/resources/application.yml + env: + spring.datasource.url: ${{ secrets.DB_URL }} + spring.datasource.username: ${{ secrets.DB_USER }} + spring.datasource.password: ${{ secrets.DB_PASSWORD }} + + # gradlew 실행 권한 부여 + - name: Grant execute permission for gradlew + run: chmod +x gradlew + shell: bash + + # 테스트를 제외한 빌드 시작 + - name: Build with Gradle + run: ./gradlew build -x test + shell: bash + + - name: Get current time + uses: 1466587594/get-current-time@v2 + id: current-time + with: + format: YYYY-MM-DD HH:mm:ss + utcOffset: '+09:00' # build 시점의 시간을 기록 + + - name: Show current time + run: echo "Current time is ${{ steps.current-time.outputs.time }}" + shell: bash + + - name: Generate deployment package + run: | + mkdir -p deploy + cp build/libs/*.jar deploy/application.jar + cp Procfile deploy/Procfile + cp -r .ebextensions_dev deploy/.ebextensions + cp -r .platform deploy/.platform + cd deploy && zip -r deploy.zip . + + # AWS Elastic Beanstalk 배포 + - name: BeanStalk Deploy + uses: einaregilsson/beanstalk-deploy@v20 + with: + aws_access_key: ${{ secrets.AWS_ACTION_ACCESS_KEY_ID }} + aws_secret_key: ${{ secrets.AWS_ACTION_SECRET_ACCESS_KEY }} + region: 'ap-northeast-2' + application_name: 'suppin-dev' + environment_name: 'suppin-dev-env' + version_label: github-action-${{ steps.current-time.outputs.formattedTime }} + deployment_package: 'deploy/deploy.zip' + wait_for_deployment: false + + + + + + + diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..d7df372 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: appstart