Skip to content

MATE-90 : [CHORE] deploy.yml 수정 #39

MATE-90 : [CHORE] deploy.yml 수정

MATE-90 : [CHORE] deploy.yml 수정 #39

Workflow file for this run

name: Deploy To EC2
on:
push
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Github Repository 파일 불러오기
uses: actions/checkout@v4
- name: JDK 17버전 설치
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Check if secret exists
if: "${{ secrets.APPLICATION_PROPERTIES != '' }}"

Check failure on line 19 in .github/workflows/deploy.yml

View workflow run for this annotation

GitHub Actions / Deploy To EC2

Invalid workflow file

The workflow is not valid. .github/workflows/deploy.yml (Line: 19, Col: 13): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.APPLICATION_PROPERTIES != ''
run: echo "Secret is set"
- name: application-dev.yml 파일 만들기
run: echo "${{ secrets.APPLICATION_PROPERTIES }}" > ./src/main/resources/application.yml
- name: 테스트 및 빌드하기
run: |
chmod +x gradlew
./gradlew clean build -Dspring.profiles.active=dev
- name: AWS Resource에 접근할 수 있게 AWS credentials 설정
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ap-northeast-2
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: ECR에 로그인하기
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Docker 이미지 생성
run: docker build -t catchmi-server .
- name: Docker 이미지에 Tag 붙이기
run: docker tag catchmi-server ${{ steps.login-ecr.outputs.registry }}/catchmi-server:latest
- name: ECR에 Docker 이미지 Push하기
run: docker push ${{ steps.login-ecr.outputs.registry }}/catchmi-server:latest
- name: 압축하기
run: tar -czvf $GITHUB_SHA.tar.gz appspec.yml scripts
- name: S3에 프로젝트 폴더 업로드하기
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.tar.gz s3://catchmi-bucket/$GITHUB_SHA.tar.gz
- name: Code Deploy를 활용해 EC2에 프로젝트 코드 배포
run: |
aws deploy create-deployment \
--application-name catchmi-server \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--deployment-group-name Develop \
--s3-location bucket=catchmi-bucket,bundleType=tgz,key=$GITHUB_SHA.tar.gz