Skip to content

Merge pull request #87 from Lets-JUPJUP/feature/post-v2 #110

Merge pull request #87 from Lets-JUPJUP/feature/post-v2

Merge pull request #87 from Lets-JUPJUP/feature/post-v2 #110

Workflow file for this run

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
name: JUPJUP CD
on:
push:
branches: [ "develop" ]
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
env: # 현재 스크립트에서 사용할 환경변수 정의
S3_BUCKET_NAME: ${{ secrets.AWS_BUCKET_NAME }}
CODE_DEPLOY_APPLICATION_NAME: lets-jupjup
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME : letsjujpup-deploy
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 11
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
shell: bash
- name : make applicaiton.yml
run: |
mkdir ./src/main/resources
touch ./src/main/resources/application.yml
echo "${{ secrets.APPLICATION_YML }}" > ./src/main/resources/application.yml
shell: bash
- name: make application-prod.yml
run: |
touch ./src/main/resources/application-prod.yml
echo "${{ secrets.APPLICATION_PROD_YML }}" > ./src/main/resources/application-prod.yml
shell: bash
- name : make service-key-jupjup.json directory
run : |
mkdir ./src/main/resources/key
- name: create-json
id: create-json
uses: jsdaniell/[email protected]
with:
name: "service-key-jupjup.json"
json: ${{ secrets.SERVICE_KEY }}
dir: './src/main/resources/key/'
- name: Build with Gradle # 프로젝트 build
run: ./gradlew clean build -x test
shell: bash
- name: Make zip file
run: zip -r ./$GITHUB_SHA.zip .
shell: bash
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_NAME }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$S3_BUCKET_NAME/$GITHUB_SHA.zip
- name: Code Deploy
run: aws deploy create-deployment --application-name $CODE_DEPLOY_APPLICATION_NAME --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name $CODE_DEPLOY_DEPLOYMENT_GROUP_NAME --s3-location bucket=$S3_BUCKET_NAME,bundleType=zip,key=$GITHUB_SHA.zip