Skip to content

Commit ad4fcad

Browse files
chore: backend cd job 추가
Co-authored-by: coli-geonwoo <[email protected]>
1 parent cfd1c32 commit ad4fcad

File tree

1 file changed

+37
-11
lines changed

1 file changed

+37
-11
lines changed

.github/workflows/backend-cicd-dev.yml

+37-11
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,41 @@ jobs:
4747
username: ${{ secrets.DOCKERHUB_USERNAME }}
4848
password: ${{ secrets.DOCKERHUB_PASSWORD }}
4949

50-
- name: Docker Build and Push
51-
uses: docker/build-push-action@v4
50+
# - name: Docker Build and Push
51+
# uses: docker/build-push-action@v4
52+
# with:
53+
# context: .
54+
# platforms: linux/amd64,linux/arm64
55+
# push: true
56+
# tags: ${{ secrets.DOCKERHUB_USERNAME }}/ody-official:${{ github.sha }}
57+
58+
- name: Docker Image Build And Push
59+
run: |
60+
docker buildx create --use
61+
docker buildx build --platform linux/amd64,linux/x64 -t ${{ secrets.DOCKERHUB_USERNAME }}/$DOCKERHUB_REPOSITORY:${{ github.sha }} -f Dockerfile . --push
62+
63+
deploy:
64+
65+
needs: build-docker-push
66+
runs-on: self-hosted
67+
permissions:
68+
contents: read
69+
70+
steps:
71+
- name: Login to Docker Hub
72+
uses: docker/[email protected]
5273
with:
53-
context: .
54-
platforms: linux/amd64,linux/arm64
55-
push: true
56-
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ DOCKERHUB_REPOSITORY }}:${{ github.sha }}
57-
58-
# - name: Docker Image Build And Push
59-
# run: |
60-
# docker buildx create --use
61-
# docker buildx build --platform linux/amd64,linux/x64 -t ${{ secrets.DOCKERHUB_USERNAME }}/$DOCKERHUB_REPOSITORY:${{ github.sha }} -f Dockerfile . --push
74+
username: ${{ secrets.DOCKERHUB_USERNAME }}
75+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
76+
77+
- name: Pull Docker image from DockerHub
78+
run: docker pull ${{ secrets.DOCKERHUB_USERNAME }}/$DOCKERHUB_REPOSITORY:${{ github.sha }}
79+
80+
- name: Stop existing Docker container
81+
run: docker stop $DOCKERHUB_REPOSITORY || true
82+
83+
- name: Remove existing Docker container
84+
run: docker rm $DOCKERHUB_REPOSITORY || true
85+
86+
- name: Run new Docker container
87+
run: docker run -d --name ody-backend -p 8080:8080 ${{ secrets.DOCKERHUB_USERNAME }}/$DOCKERHUB_REPOSITORY:${{ github.sha }}

0 commit comments

Comments
 (0)