Skip to content

Commit

Permalink
Feat: CI / CD 파이프라인 구축 (#2)
Browse files Browse the repository at this point in the history
* Feat: CI 파일 추가

* Feat: CD 파일 추가

* Fix: buildBootImage에 생성 일자 추가
  • Loading branch information
Jaewon-pro authored Jul 20, 2024
1 parent e5aa835 commit 41dbf8f
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: CD

on:
push:
branches:
- main

permissions:
contents: read

jobs:
cd:
runs-on: ubuntu-22.04
env:
IMAGE_TAG: ${{ github.sha }}
REPO: ${{ secrets.DOCKER_REPOSITORY }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3

- name: Execute Gradle build
run: ./gradlew clean :bootBuildImage --imageName=$REPO:$IMAGE_TAG

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Publish Docker image
run: |
echo "Pushing Docker image with tag: $IMAGE_TAG"
docker push $REPO:$IMAGE_TAG
- name: Send command by AWS SSM
uses: peterkimzz/aws-ssm-send-command@master
id: ssm
with:
aws-region: ap-northeast-2
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
instance-ids: ${{ secrets.AWS_INSTANCE_ID }}
working-directory: ${{ vars.DEPLOY_SCRIPT_PATH }}
command: |
echo "############# PULL DOCKER IMAGE #############"
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }}
docker pull ${{ env.REPO }}:${{ env.IMAGE_TAG }}
echo "############# RUN DEPLOY SCRIPT #############"
sh deploy.sh ${{ env.REPO }} ${{ env.IMAGE_TAG }}
33 changes: 33 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

permissions:
contents: read

jobs:
ci:
runs-on: ubuntu-22.04

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3

- name: Test with Gradle
run: ./gradlew clean test --stacktrace --parallel
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ dependencies {
tasks.withType<Test> {
useJUnitPlatform()
}

tasks.bootBuildImage {
createdDate = "now"
}

0 comments on commit 41dbf8f

Please sign in to comment.