Ijuju backend deploy #68
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: Ijuju backend deploy | |
on: | |
workflow_dispatch: | |
env: | |
DOCKER_IMAGE: ghcr.io/childlearn/ijuju-backend | |
VERSION: ${{ github.sha }} | |
NAME: ijuju_backend | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: ๋ ํฌ์งํ ๋ฆฌ ์ฒดํฌ์์ | |
uses: actions/checkout@v4 | |
- name: application-prod.yml ์์ฑ | |
run: | | |
mkdir -p ./src/main/resources | |
echo "${{ secrets.APPLICATION_PROD }}" > ./src/main/resources/application-prod.yml | |
- name: JDK 17 ์ค์น | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 17 | |
- name: ๊ถํ ๋ถ์ฌ ๋ฐ gradle ๋น๋ | |
run: | | |
chmod +x ./gradlew | |
./gradlew clean build -x test | |
- name: Set up docker buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to ghcr | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GHCR_TOKEN }} | |
- name: Build and push | |
run: | | |
docker build -t ${{ env.DOCKER_IMAGE }}:${{ github.sha }} . | |
docker tag ${{ env.DOCKER_IMAGE }}:${{ github.sha }} ${{ env.DOCKER_IMAGE }}:latest | |
docker push ${{ env.DOCKER_IMAGE }}:${{ github.sha }} | |
docker push ${{ env.DOCKER_IMAGE }}:latest | |
deploy: | |
needs: build | |
name: Deploy | |
runs-on: self-hosted | |
steps: | |
- name: Login to ghcr | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GHCR_TOKEN }} | |
- name: Pull Docker image | |
run: | | |
docker pull ${{ env.DOCKER_IMAGE }}:latest | |
- name: Docker run | |
run: | | |
docker stop ${{ env.NAME }} && docker rm ${{ env.NAME }} && docker rmi ${{ env.DOCKER_IMAGE }}:latest | |
docker run -d -p 8080:8080 --name ${{ env.NAME }} --restart always -e TZ=Asia/Seoul ${{ env.DOCKER_IMAGE }}:latest | |
docker image prune -f |