✏️ .gitignore 변경 #3
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: cicd-dev | |
on: | |
push: | |
branches: [ "main" ] | |
env: | |
AWS_REGION: ap-northeast-2 | |
ECR_REPOSITORY: new_morandi_batch | |
ECR_REGISTRY: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.ap-northeast-2.amazonaws.com/new_morandi_batch | |
GITHUB_SHA: ${{ github.sha }} | |
permissions: | |
contents: read | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# Gradle 빌드를 추가합니다. | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v2 | |
with: | |
distribution: 'adopt' | |
java-version: '17' | |
- name: Cleanup application.yml | |
run: rm -f src/main/resources/application.yml | |
# GitHub Secret에서 application-prod.yml 내용을 불러와 파일로 저장 | |
- name: Create application.yml from GitHub Secret | |
run: | | |
mkdir -p src/main/resources | |
echo "${{ secrets.DEV_APPLICATION_YML }}" > src/main/resources/application.yml | |
- name: Build with Gradle | |
env: | |
ORG_GRADLE_OPTS: "-Duser.timezone=Asia/Seoul" | |
run: ./gradlew clean bootJar -x test | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.ECR_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.ECR_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.AWS_REGION }} | |
mask-aws-account-id: true | |
- name: Login to Private ECR | |
run: aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin ${{ env.ECR_REGISTRY }} | |
- name: Build Docker Image | |
run: docker build -t ${{ env.ECR_REGISTRY }}:${{ github.sha }} . | |
- name: Push Docker Image to ECR | |
run: docker push ${{ env.ECR_REGISTRY }}:${{ github.sha }} |