Skip to content

feat: modify workflows #3

feat: modify workflows

feat: modify workflows #3

name: Dockerizing to ECR
on:
push:
branches:
- dev-gureumi
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
tags:
description: 'Test Deploy'
jobs:
build:
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
steps:
#체크아웃
- name: Checkout code
uses: actions/checkout@v3
# JDK 설치
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
# Gradle 세팅
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
# gradlew 권한 변경
- name: Grant execute permission for gradlew
run: chmod +x gradlew
# 빌드(test는 제외)
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: clean build -x test
# ECR 로그인
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
# Docker 이미지 빌드
- name: Docker 이미지 빌드
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -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