File tree 1 file changed +9
-5
lines changed
1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 71
71
# Build Docker Image
72
72
- name : Build Docker image
73
73
run : |
74
- docker build -t devops-nextjs:${{ github.sha }} .
74
+ # Use the first 7 characters of the GitHub SHA for a shorter, valid Docker tag
75
+ SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
76
+ docker build -t my-app:${SHORT_SHA} .
75
77
76
78
# Log in to Docker Hub
77
79
- name : Log in to Docker Hub
@@ -80,11 +82,13 @@ jobs:
80
82
# Tag Docker image
81
83
- name : Tag Docker image
82
84
run : |
83
- docker tag devops-nextjs:${{ github.sha }} ${{ secrets.DOCKER_USERNAME }}/devops-nextjs:${{ github.sha }}
84
- docker tag devops-nextjs:${{ github.sha }} ${{ secrets.DOCKER_USERNAME }}/devops-nextjs:latest
85
+ SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
86
+ docker tag my-app:${SHORT_SHA} ${{ secrets.DOCKER_USERNAME }}/my-app:${SHORT_SHA}
87
+ docker tag my-app:${SHORT_SHA} ${{ secrets.DOCKER_USERNAME }}/my-app:latest
85
88
86
89
# Push Docker image to Docker Hub
87
90
- name : Push Docker image
88
91
run : |
89
- docker push ${{ secrets.DOCKER_USERNAME }}/devops-nextjs:${{ github.sha }}
90
- docker push ${{ secrets.DOCKER_USERNAME }}/devops-nextjs:latest
92
+ SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
93
+ docker push ${{ secrets.DOCKER_USERNAME }}/my-app:${SHORT_SHA}
94
+ docker push ${{ secrets.DOCKER_USERNAME }}/my-app:latest
You can’t perform that action at this time.
0 commit comments