Skip to content

Commit fc04e02

Browse files
author
NOTEBOOK-SAUER\chris
committed
adapt docker tag name to fit
1 parent 2bde052 commit fc04e02

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

.github/workflows/nextjs.yml

+9-5
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ jobs:
7171
# Build Docker Image
7272
- name: Build Docker image
7373
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} .
7577
7678
# Log in to Docker Hub
7779
- name: Log in to Docker Hub
@@ -80,11 +82,13 @@ jobs:
8082
# Tag Docker image
8183
- name: Tag Docker image
8284
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
8588
8689
# Push Docker image to Docker Hub
8790
- name: Push Docker image
8891
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

0 commit comments

Comments
 (0)