[4주차 서버 병합] (#179) #25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
branches: [ main ] | |
env: | |
S3_BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET }} | |
PROJECT_NAME: ${{ github.repository }} | |
jobs: | |
build: | |
name: CD | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '17' | |
distribution: 'zulu' | |
- name: Copy YML | |
env: | |
OCCUPY_YML: ${{ secrets.OCCUPY_YML }} | |
OCCUPY_YML_DIR: ./BE/src/main/resources | |
OCCUPY_YML_DIR_FILE_NAME: application.yml | |
run: echo $OCCUPY_YML | base64 --decode > $OCCUPY_YML_DIR/$OCCUPY_YML_DIR_FILE_NAME | |
- name: Copy FB JSON | |
env: | |
OCCUPY_FB: ${{ secrets.OCCUPY_FB }} | |
OCCUPY_FB_DIR: ./BE/src/main/resources | |
OCCUPY_FB_DIR_FILE_NAME: fbServiceAccountKey.json | |
run: echo $OCCUPY_FB | base64 --decode > $OCCUPY_FB_DIR/$OCCUPY_FB_DIR_FILE_NAME | |
- name: Grant execute permission for gradlew | |
run: chmod +x ./BE/gradlew | |
- name: Print current working directory | |
run: ls -lR | |
- name: Build with Gradle | |
run: ./gradlew clean build --exclude-task test | |
working-directory: ./BE/ | |
- name: Make zip file | |
run: zip -r ./$GITHUB_SHA.zip . | |
env: | |
GITHUB_SHA: ${{ github.sha }} | |
- 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: ${{ secrets.AWS_REGION }} | |
- name: Copy script | |
run: cp ./scripts/*.sh ./deploy | |
- name: Upload to S3 | |
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$S3_BUCKET_NAME/$PROJECT_NAME/$GITHUB_SHA.zip | |
env: | |
GITHUB_SHA: ${{ github.sha }} | |
- name: Deploy | |
run: | | |
aws deploy create-deployment \ | |
--application-name 6four \ | |
--deployment-config-name CodeDeployDefault.AllAtOnce \ | |
--deployment-group-name cicd-6four \ | |
--file-exists-behavior OVERWRITE \ | |
--s3-location bucket=$S3_BUCKET_NAME,bundleType=zip,key=$PROJECT_NAME/$GITHUB_SHA.zip \ | |
--region ap-northeast-2 \ |