Skip to content

chore: backend cd job 오류 수정 #15

chore: backend cd job 오류 수정

chore: backend cd job 오류 수정 #15

name: backend cicd dev
on:
push:
branches: [ "feature/19" ]
# paths:
# - backend/**
pull_request:
branches: [ "feature/19" ]
# paths:
# - backend/**
defaults:
run:
working-directory: backend
env:
DOCKERHUB_REPOSITORY: ody-official
jobs:
build-docker-push:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- run: ls -al
with:

Check failure on line 30 in .github/workflows/backend-cicd-dev.yml

View workflow run for this annotation

GitHub Actions / backend cicd dev

Invalid workflow file

The workflow is not valid. .github/workflows/backend-cicd-dev.yml (Line: 30, Col: 9): Unexpected value 'with'
ref: develop
- run: ls -al
- 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 Build and Push
# uses: docker/build-push-action@v4
# with:
# context: .
# platforms: linux/amd64,linux/arm64
# push: true
# tags: ${{ secrets.DOCKERHUB_USERNAME }}/ody-official:${{ github.sha }}
- name: Docker Image Build And Push
run: |
docker buildx create --use
docker buildx build --platform linux/amd64,linux/x64 -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 ${{ 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 }}