Skip to content

Commit

Permalink
๐Ÿ‘ท CI ๋นŒ๋“œ ์‹œ์Šคํ…œ ์ถ”๊ฐ€
Browse files Browse the repository at this point in the history
- build.yml์„ ์ƒ์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค.
  • Loading branch information
Ganghee-Lee-0522 authored Jan 11, 2024
1 parent e4fef59 commit f439886
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Java CI with Gradle

on:
push:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v3

# JDK๋ฅผ 17 ๋ฒ„์ „์œผ๋กœ ์„ธํŒ…
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

# Gradle ์บ์‹ฑ-> ๋นŒ๋“œ ์†๋„ UP
- name: Gradle caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# application.yml ํŒŒ์ผ ์ƒ์„ฑ
- name: make application.yaml
run: |
cd ./src/main/resources
touch ./application.yml
echo "${{ secrets.APPLICATION }}" >> ./application.yml
shell: bash

# Gradle๋กœ ๋นŒ๋“œ ์‹คํ–‰
- name: Build with Gradle
run: ./gradlew bootJar

# image๋กœ๋ถ€ํ„ฐ Metadata ์ถ”์ถœ
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}
tags: |
type=sha
# image ๋นŒ๋“œ ๋ฐ ๋„์ปคํ—ˆ๋ธŒ์— push
- name: web docker build and push
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_ACCESS_TOKEN }}
docker build -t ${{ secrets.DOCKER_REPO }}/kidari:${{ steps.meta.outputs.version }} .
docker push ${{ secrets.DOCKER_REPO }}/kidari:${{ steps.meta.outputs.version }}
# ๋นŒ๋“œ ๊ฒฐ๊ณผ Slack ์•Œ๋žŒ ์ „์†ก
- name: Send Slack Alarms
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: general
SLACK_COLOR: ${{ job.status }} # or a specific color like 'good' or '#ff00ff'
SLACK_ICON: https://github.com/rtCamp.png?size=48
SLACK_MESSAGE: ๋นŒ๋“œ ๊ฒฐ๊ณผ => ${{ job.status }}
SLACK_TITLE: ๋นŒ๋“œ ๊ฒฐ๊ณผ ์•Œ๋žŒ
SLACK_USERNAME: Notification-Bot
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
if: always()

0 comments on commit f439886

Please sign in to comment.