Code Deploy Error Fix #27
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
# 자바 프로젝트를 위한 Gradle을 사용한 지속적 배포(CD) 워크플로우 설정 | |
name: CD with Gradle | |
# main 브랜치로 push되거나 pull request가 발생했을 때 워크플로우를 실행 | |
on: | |
push: | |
branches: [ "develop" ] | |
pull_request: | |
branches: [ "develop" ] | |
# 워크플로우에서는 저장소 내용을 읽을 수 있는 권한만 설정 | |
permissions: | |
contents: read | |
# 워크플로우에서 실행될 작업들을 정의 | |
jobs: | |
build: | |
runs-on: ubuntu-latest # 작업을 실행할 환경으로 ubuntu 최신 버전을 사용 | |
steps: | |
# 실행주체: GitHub Actions > GitHub Infra | |
# 첫 번째 단계: 워크플로우를 트리거한 커밋에서 저장소 코드를 체크아웃 | |
- uses: actions/checkout@v3 | |
# 두 번째 단계: Java Development Kit(JDK) 버전 17을 설정 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: "adopt" | |
# 세 번째 단계: GitHub secrets에서 데이터를 가져와 application.properties 파일 생성 | |
- name: Make application.yaml | |
run: | | |
cd ./src/main/resources | |
touch ./application.yaml | |
echo "${{ secrets.APPLICATION_YAML }}" > ./application.yaml | |
echo "${{ secrets.AWS_KEYSTORE }}" | base64 --decode > ./keystore-aws.p12 | |
cd ../../test/resources | |
touch ./application.yaml | |
echo "${{ secrets.APPLICATION_TEST_YAML }}" > ./application.yaml | |
shell: bash | |
# 네 번째 단계: Gradle을 사용해 프로젝트 빌 | |
- name: Build with Gradle | |
run: | | |
chmod +x ./gradlew | |
./gradlew clean build | |
# 전송할 파일을 담을 디렉토리 생성 | |
- name: Make Directory for deliver | |
run: mkdir deploy | |
# Jar 파일 Copy | |
- name: Copy Jar | |
run: | | |
cp ./build/libs/*.jar ./deploy/ | |
cp ./appspec.yml ./deploy/ | |
cp -r ./scripts ./deploy/ | |
- name: Deliver to AWS S3 | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-region: ap-southeast-2 | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
- name: S3에 업로드 | |
run: aws deploy push --application-name ${{ secrets.AWS_CODE_DEPLOY_APPLICATION }} --ignore-hidden-files --s3-location s3://gamemuncheol-s3/deploy.zip --source ./deploy | |
- name: EC2에 배포 | |
run: aws deploy create-deployment --application-name ${{ secrets.AWS_CODE_DEPLOY_APPLICATION }} --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name ${{ secrets.AWS_CODE_DEPLOY_APPLICATION }} --s3-location bucket=gamemuncheol-s3,key=deploy.zip,bundleType=zip |