chore: backend cicd yml 주석 제거 #25
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: backend cicd dev | |
on: | |
push: | |
branches: [ "feature/19" ] | |
# paths: | |
# - backend/** | |
pull_request: | |
branches: [ "feature/19" ] | |
# paths: | |
# - backend/** | |
env: | |
DOCKERHUB_REPOSITORY: ody-official | |
jobs: | |
build-docker-push: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
defaults: | |
run: | |
working-directory: backend | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: develop | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 | |
- name: Build with Gradle Wrapper | |
run: ./gradlew build | |
- name: Setup Docker buildx | |
uses: docker/[email protected] | |
- name: Login to Docker Hub | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Docker Image Build And Push | |
run: docker build --platform linux/x64/v8 -t ${{ secrets.DOCKERHUB_USERNAME }}/$DOCKERHUB_REPOSITORY:${{ github.sha }} -f Dockerfile . --push | |
docker-pull-deploy: | |
needs: build-docker-push | |
runs-on: self-hosted | |
steps: | |
- name: Login to Docker Hub | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Pull Docker image from DockerHub | |
run: docker pull --platform linux/x64/v8 ${{ secrets.DOCKERHUB_USERNAME }}/$DOCKERHUB_REPOSITORY:${{ github.sha }} | |
- name: Stop existing Docker container | |
run: docker stop $DOCKERHUB_REPOSITORY || true | |
- name: Remove existing Docker container | |
run: docker rm $DOCKERHUB_REPOSITORY || true | |
- name: Run new Docker container | |
run: docker run -d --name ody-backend -p 8080:8080 ${{ secrets.DOCKERHUB_USERNAME }}/$DOCKERHUB_REPOSITORY:${{ github.sha }} |