[Cd/10] Docker, Elastic Beanstalk ํ์ฉํ ๋ฌด์ค๋จ CICD ๊ตฌ์ถ #70
Workflow file for this run
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: 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 |