[LIME-7] github action의 yml 파일 수정 #24
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 | |
on: | |
pull_request: | |
branches: | |
- main | |
types: [closed] | |
permissions: | |
contents: read | |
jobs: | |
build-docker-image: | |
if: github.event.pull_request.merged | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Set YML | |
run: | | |
mkdir -p lime-api/src/main/resources | |
echo "${{ secrets.APPLICATION_YML }}" | base64 --decode > lime-api/src/main/resources/application.yml | |
echo "${{ secrets.APPLICATION_API_YML }}" | base64 --decode > lime-api/src/main/resources/application-api.yml | |
find lime-api/src | |
mkdir -p lime-domain/src/main/resources | |
echo "${{ secrets.APPLICATION_DOMAIN_YML }}" | base64 --decode > lime-domain/src/main/resources/application-domain.yml | |
find lime-domain/src | |
mkdir -p lime-infrastructure/src/main/resources | |
echo "${{ secrets.APPLICATION_INFRA_YML }}" | base64 --decode > lime-infrastructure/src/main/resources/application-infra.yml | |
find lime-infrastructure/src | |
- name: Build with Gradle | |
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 | |
with: | |
arguments: clean bootJar | |
- name: docker image build | |
run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/lime-image . | |
- name: docker login | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: docker Hub push | |
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/lime-image | |
run-docker-image-on-server: | |
if: github.event.pull_request.merged | |
needs: build-docker-image | |
runs-on: self-hosted | |
steps: | |
- name: docker pull | |
run: sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/lime-image | |
- name: docker stop container | |
run: sudo docker stop $(sudo docker ps -q) 2>/dev/null || true | |
- name: docker run new container | |
run: sudo docker run --name lime-image --rm -d -p 8080:8080 ${{ secrets.DOCKERHUB_USERNAME }}/lime-image | |
- name: delete old docker image | |
run: sudo docker system prune -f |