β¨ REINPUT backend DEV CD β¨ #49
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: β¨ REINPUT backend DEV CD β¨ | |
env: | |
PROFILE: prod | |
DOCKER_HUB_REPOSITORY: ahchjang/reinput # docker μ€μ ν κ² | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
paths: | |
- "/**" | |
- "src/**" | |
- ".github/workflows/reinput.yml" | |
jobs: | |
backend-docker-build-and-push: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./ | |
steps: | |
- name: β¨ Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
token: ${{ secrets.ACTION_TOKEN }} | |
- name: β¨ JDK 17 μ€μ | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- 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- | |
- name: β¨ Gradlew κΆν μ€μ | |
run: chmod +x ./gradlew | |
- name: β¨ Jar νμΌ λΉλ | |
run: ./gradlew bootJar | |
- name: β¨ DockerHubμ λ‘κ·ΈμΈ | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
- name: β¨ Docker Image λΉλ ν DockerHubμ Push | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./ | |
file: ./Dockerfile | |
push: true | |
platforms: linux/amd64 | |
tags: ${{ env.DOCKER_HUB_REPOSITORY }}:latest | |
build-args: | | |
SPRING_PROFILES_ACTIVE=${{ env.PROFILE }} | |
backend-docker-pull-and-run: | |
runs-on: [ self-hosted, dev ] | |
if: ${{ needs.backend-docker-build-and-push.result == 'success' }} | |
needs: [ backend-docker-build-and-push ] | |
steps: | |
- name: β¨ λ°°ν¬ μ€ν¬λ¦½νΈ μ€ν | |
run: | | |
sh /home/ubuntu/deploy.sh |