@@ -47,15 +47,41 @@ jobs:
47
47
username : ${{ secrets.DOCKERHUB_USERNAME }}
48
48
password : ${{ secrets.DOCKERHUB_PASSWORD }}
49
49
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
+
52
73
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