Skip to content

Merge pull request #254 from Garodden/Garodden-patch-5 #160

Merge pull request #254 from Garodden/Garodden-patch-5

Merge pull request #254 from Garodden/Garodden-patch-5 #160

Workflow file for this run

name: github-action-workflow
on:
push:
branches: [ "develop" ]
env:
S3_BUCKET_NAME: thlee-content
AWS_REGION: ap-northeast-2
CODEDEPLOY_NAME: github-actions
CODEDEPLOY_GROUP: thlee-github-actions-group
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Github checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Change application.yml to deploy version
run: |
cd ./src/main/resources
mv ./application-deploy.yml ./application.yml
cat application.yml
- name: Make application-secret.yml
env:
JWT_TOKEN_SECRET: ${{ secrets.JWT_TOKEN_SECRET }}
MYSQL_URL: ${{secrets.AWS_RDS_URL}}
MYSQL_USERNAME: ${{secrets.AWS_RDS_USERNAME}}
MYSQL_PASSWORD: ${{secrets.AWS_RDS_PASSWORD}}
NAVER_CLIENT: ${{secrets.NAVER_CLIENT}}
NAVER_KEY: ${{secrets.NAVER_KEY}}
P12_KEY_PASSWORD: ${{secrets.P12_KEY_PASSWORD}}
run: |
cd ./src/main/resources
echo -e \
"
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: $MYSQL_URL
username: $MYSQL_USERNAME
password: $MYSQL_PASSWORD
jpa:
properties:
hibernate:
show_sql: true
format_sql: true
dialect: org.hibernate.dialect.MySQL8Dialect
hibernate:
ddl-auto: none
servlet:
multipart:
enabled: true
max-file-size: 10MB
max-request-size: 10MB
profiles:
include: API-KEY
jwt:
secret: $JWT_TOKEN_SECRET
naver-client: $NAVER_CLIENT
naver-key: $NAVER_KEY
server:
port: 443
ssl:
key-store: file:/home/ec2-user/action/src/main/resources/keystore.p12
key-store-type: PKCS12
key-store-password: $P12_KEY_PASSWORD
" > application-security.yml
- name: Make application-temp.properties
env:
NAVER_CLIENT: ${{secrets.NAVER_CLIENT}}
NAVER_KEY: ${{secrets.NAVER_KEY}}
run: |
cd ./src/main/resources
echo -e \
"
naver-client=$NAVER_CLIENT
naver-key=$NAVER_KEY
" > application-temp.properties
- name: Change application-temp.properties to deploy version
run: |
cd ./src/main/resources
mv ./application-temp.properties ./application-API-KEY.properties
cat application-API-KEY.properties
- name: Change application-security.yml to deploy version
run: |
cd ./src/main/resources
mv ./application-security.yml ./application.yml
cat application.yml
- name: Grant excute permission for gradlew
run: chmod +x gradlew
- name: Setup Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
- name: Build with Gradle Wrapper
run: ./gradlew -x test build
- name: Make zip file
run: zip -r ./$GITHUB_SHA.zip .
shell: bash
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://thlee-content/$GITHUB_SHA.zip
- name: Code Deploy
run: aws deploy create-deployment --application-name $CODEDEPLOY_NAME --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name $CODEDEPLOY_GROUP --s3-location bucket=$S3_BUCKET_NAME,bundleType=zip,key=$GITHUB_SHA.zip