Skip to content

Merge pull request #107 from TeamSobokSobok/develop #17

Merge pull request #107 from TeamSobokSobok/develop

Merge pull request #107 from TeamSobokSobok/develop #17

Workflow file for this run

name: Sobok-server CD
on:
push:
branches: [ main ]
env:
S3_BUCKET_NAME: sobok-storage
jobs:
build:
name: Code deployment
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: make application.yml 파일 생성
run: |
cd ./src/main/resources
# application.yml 파일 생성
touch ./application.yml
# firebase 폴더 생성
mkdir firebase
# firebase admin-sdk 파일 생성
touch ./firebase/soboksobok-564b3-firebase-adminsdk-l4k48-58b981ed69.json
# Github-Actions 에서 설정한 값을 json 파일에 입력
echo "${{ secrets.SOBOKSOBOK_FIREBASE }}" >> ./firebase/soboksobok-564b3-firebase-adminsdk-l4k48-58b981ed69.json
# GitHub-Actions 에서 설정한 값을 application.yml 파일에 쓰기
echo "${{ secrets.SOBOKSOBOK_DEPLOY }}" >> ./application.yml
shell: bash
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build -x test
- name: Make Directory
run: mkdir -p deploy
- name: Copy Jar
run: cp ./build/libs/*.jar ./deploy
- name: Copy appspec.yml
run: cp appspec.yml ./deploy
- name: Copy script
run: cp ./scripts/*.sh ./deploy
- name: Make zip file
run: zip -r ./sobok_server.zip ./deploy
shell: bash
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_DEPLOYER_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_DEPLOYER_SECRET_KEY }}
aws-region: ap-northeast-2
- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./sobok_server.zip s3://$S3_BUCKET_NAME/
# Deploy
- name: Deploy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_DEPLOYER_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_DEPLOYER_SECRET_KEY }}
run:
aws deploy create-deployment
--application-name sobok-server-code-deploy
--deployment-group-name sobok-server-code-deploy-group
--file-exists-behavior OVERWRITE
--s3-location bucket=sobok-storage,bundleType=zip,key=sobok_server.zip
--region ap-northeast-2