Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: CI workflow #16

Merged
merged 5 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build and Push Docker Image to AWS ECR

on:
push:
branches: [develop]
pull_request:
branches: [develop] # develop λΈŒλžœμΉ˜μ— push/pr ν–ˆμ„ λ•Œ workflowλ₯Ό trigger함.

jobs:
build-and-push-image:
runs-on: ubuntu-latest
steps:
# μ½”λ“œ λ‚΄λ €λ°›κΈ°
- name: Checkout source code
uses: actions/checkout@v2

# μžλ°” 버전 μ„ΈνŒ…
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: '17'
distribution: 'temurin'

# λΉŒλ“œ κΆŒν•œ λΆ€μ—¬
- name: Grant execute permission for gradlew
run: chmod +x gradlew

# λΉŒλ“œ
- name: Build with Gradle
run: ./gradlew clean build -x test

# AWS 자격 증λͺ…
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2

# AWS ECR 둜그인
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

# Image λΉŒλ“œ 및 ECR에 Push μˆ˜ν–‰
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY_NAME }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker buildx build --platform=linux/amd64 -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM openjdk:17

ARG JAR_PATH=build/libs/fullcar-0.0.1-SNAPSHOT.jar

COPY ${JAR_PATH} fullcar.jar

ENTRYPOINT ["java","-jar","/fullcar.jar"]
Loading