Merge branch 'dev' of github.com:innovationacademy-kr/42cabi into be/… #436
Workflow file for this run
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
name: CI/CD | |
on: | |
push: | |
paths: | |
- "backend/**" | |
workflow_dispatch: | |
jobs: | |
backend-CI: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Make ssh file | |
run: | | |
mkdir -p ~/.ssh | |
echo '${{ secrets.SSH_CONFIG }}' | base64 -d > ~/.ssh/id_rsa | |
chmod 400 ~/.ssh/id_rsa | |
- name: 체크아웃 | |
uses: actions/checkout@v3 | |
with: | |
submodule: true | |
- name: 서브모듈 업데이트 | |
run: | | |
git submodule update --init config | |
- name: JDK 11 설정 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: "11" | |
distribution: "corretto" | |
- name: Setup SSH key to access private submodule | |
run: | | |
mkdir -p ~/.ssh | |
echo '${{ secrets.CONFIG_DEV_PRIVATE_KEY }}' | base64 -d > ~/.ssh/id_rsa | |
chmod 400 ~/.ssh/id_rsa | |
# 리포지토리로 체크아웃을 진행하고 서브모듈을 참조하여 clone한다. | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodule: true | |
# submodule의 내용을 update한다. | |
- name: Update config submodule | |
run: | | |
git submodule update --init | |
- name: Cache Gradle packages | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Gradle 빌드 | |
run: | | |
cd backend | |
mkdir -p build/generated-snippets/ | |
chmod +x gradlew | |
./gradlew build -x test | |
shell: bash | |
- name: Configure AWS credentials | |
if: ${{ github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main' }} | |
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: Dev S3에 업로드 | |
if: ${{ github.ref == 'refs/heads/dev' }} | |
run: | | |
echo "${{ secrets.PINPOINT_APPLICATION_DEV_ENV }}" | base64 --decode > deploy-dev/pinpoint-application/.env | |
echo "${{ secrets.PINPOINT_AGENT_DEV_ENV }}" | base64 --decode > deploy-dev/pinpoint-agent/.env | |
cp backend/build/libs/cabinet-*.jar deploy-dev/pinpoint-application/build | |
mkdir -p deploy && cp -r deploy-dev/* deploy/ | |
zip -r deploy.zip deploy | |
aws s3 cp deploy.zip s3://${{ secrets.AWS_S3_DEV_BUCKET_NAME }}/deploy.zip | |
aws deploy create-deployment \ | |
--application-name ${{ secrets.AWS_CODEDEPLOY_DEV_APP_NAME }} \ | |
--deployment-config-name CodeDeployDefault.AllAtOnce \ | |
--deployment-group-name ${{ secrets.AWS_CODEDEPLOY_DEV_GROUP_NAME }} \ | |
--file-exists-behavior OVERWRITE \ | |
--s3-location bucket=${{ secrets.AWS_S3_DEV_BUCKET_NAME }},bundleType=zip,key=deploy.zip | |
- name: Main S3에 업로드 | |
if: ${{ github.ref == 'refs/heads/main' }} | |
run: | | |
echo "${{ secrets.PINPOINT_APPLICATION_PROD_ENV }}" | base64 --decode > deploy-main/pinpoint-application/.env | |
echo "${{ secrets.PINPOINT_AGENT_PROD_ENV }}" | base64 --decode > deploy-main/pinpoint-agent/.env | |
cp backend/build/libs/cabinet-*.jar deploy-main/pinpoint-application/build | |
mkdir -p deploy && cp -r deploy-main/* deploy/ | |
zip -r deploy.zip deploy | |
aws s3 cp deploy.zip s3://${{ secrets.AWS_S3_MAIN_BUCKET_NAME }}/deploy.zip | |
aws deploy create-deployment \ | |
--application-name ${{ secrets.AWS_CODEDEPLOY_MAIN_APP_NAME }} \ | |
--deployment-config-name CodeDeployDefault.AllAtOnce \ | |
--deployment-group-name ${{ secrets.AWS_CODEDEPLOY_MAIN_GROUP_NAME }} \ | |
--file-exists-behavior OVERWRITE \ | |
--s3-location bucket=${{ secrets.AWS_S3_MAIN_BUCKET_NAME }},bundleType=zip,key=deploy.zip |