Java CICD with Gradle & Docker #98
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: | |
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 | |
# 환경 변수 설정 (0) | |
- name: Set Yaml | |
uses: microsoft/variable-substitution@v1 | |
with: | |
files: ./src/main/resources/application.yml | |
env: | |
spring.datasource.url: ${{ secrets.DB_URL }} | |
spring.datasource.username: ${{ secrets.DB_USERNAME }} | |
spring.datasource.password: ${{ secrets.DB_PASSWORD }} | |
# 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 |