Skip to content

[Cd/10] Docker, Elastic Beanstalk ํ™œ์šฉํ•œ ๋ฌด์ค‘๋‹จ CICD ๊ตฌ์ถ• #70

[Cd/10] Docker, Elastic Beanstalk ํ™œ์šฉํ•œ ๋ฌด์ค‘๋‹จ CICD ๊ตฌ์ถ•

[Cd/10] Docker, Elastic Beanstalk ํ™œ์šฉํ•œ ๋ฌด์ค‘๋‹จ CICD ๊ตฌ์ถ• #70

Workflow file for this run

name: Java CICD with Gradle & Docker
on:
push:
branches: [ "develop", "feat/*", "cd/*", "fix/*", "hotfix/*", "refactor/*", "chore/*", "docs/*", "style/*", "test/*" ]
pull_request:
types : [ closed ]
workflow_dispatch: # ์ˆ˜๋™ ์‹คํ–‰ ๊ฐ€๋Šฅ
jobs:
build-and-push-image:
runs-on: ubuntu-latest
steps:
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Checkout
uses: actions/checkout@v3
# Spring Boot ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ Build (1)
- name: Spring Boot Build
run: ./gradlew clean build -x test --warning-mode=all --stacktrace
# Docker ์ด๋ฏธ์ง€ Build (2)
- name: docker image build
run: docker build -t rimi3226/gamegoo .
# DockerHub Login (3)
- name: docker login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PW }}
# Docker Hub push (4)
- name: docker Hub push
run: docker push rimi3226/gamegoo
# Configure AWS Credentials (6) - AWS ์ ‘๊ทผ ๊ถŒํ•œ ์ทจ๋“(IAM)
- 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
# Build ๋ฒˆํ˜ธ ๋ถ€์—ฌ (7)
- name: Build Number
id: build-number
run: echo "::set-output name=BUILD_NUMBER::$(date '+%-d.%-m.%Y.%-H.%-M.%-S')"
# Elastic Beanstalk Deploy with docker (8)
- name: Deploy to EB
uses: einaregilsson/beanstalk-deploy@v20
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: Gamegoo
environment_name: Gamegoo-env
region: ap-northeast-2
version_label: ${{ steps.build-number.outputs.BUILD_NUMBER }}
deployment_package: ./elasticbeanstalk/docker-compose.yml