[IDLE-248] config: Dockerfile 수정 및 shell script 추가 #78
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: 'book-service upload ecr & ecs' | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- 'backend/book-service/**' | |
pull_request: | |
branches: | |
- master | |
paths: | |
- 'backend/book-service/**' | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Setup Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: '17' | |
- name: Setup Application Test Yaml | |
uses: microsoft/variable-substitution@v1 | |
with: | |
files: backend/book-service/src/main/resources/application-test.yml | |
env: | |
aladin.api.key: ${{ secrets.ALADIN_API_KEY }} | |
kakao.api.key: ${{ secrets.KAKAO_API_KEY }} | |
- name: Setup Bootstrap Yaml For Test | |
uses: microsoft/variable-substitution@v1 | |
with: | |
files: backend/book-service/src/main/resources/bootstrap.yml | |
env: | |
spring.profiles.active: test | |
- name: Test with Gradle | |
working-directory: backend/book-service | |
run: | | |
./gradlew test | |
- name: Setup Bootstrap Yaml For Build | |
uses: microsoft/variable-substitution@v1 | |
with: | |
files: backend/book-service/src/main/resources/bootstrap.yml | |
env: | |
spring.profiles.active: prod | |
- name: Build with Gradle | |
working-directory: backend/book-service | |
run: | | |
./gradlew clean build -x test | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ECR_ECS_ACCESS_KEY }} | |
aws-secret-access-key: ${{ secrets.AWS_ECR_ECS_SECRET_KEY }} | |
aws-region: ${{ secrets.ECR_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Build, tag, and push image to Amazon ECR | |
id: build-image | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: ${{ secrets.ECR_BOOK_SERVICE_REPOSITORY }} | |
IMAGE_TAG: ${{ github.sha }} | |
working-directory: backend/book-service | |
run: | | |
docker build --platform amd64 -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT |