Skip to content

Commit 9770158

Browse files
authored
Merge pull request #47 from amfoss/praveshan-develop
modify workflow
2 parents dd0cbc2 + 98e0bca commit 9770158

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

.github/workflows/ghcr-deploy.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ jobs:
2727
- name: Checkout the repo
2828
uses: actions/checkout@v2
2929

30-
- name: Build container image
31-
run: docker build -t $(echo $REGISTRY)/$(echo $IMAGE_NAME):$(echo $GITHUB_SHA | head -c7) .
30+
- name: Build and tag container image
31+
run: |
32+
# Tag the image with both 'latest' and the specific commit SHA
33+
docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} .
3234
3335
- name: Install doctl
3436
uses: digitalocean/action-doctl@v2
@@ -42,7 +44,10 @@ jobs:
4244
run: if [ ! -z "$(doctl registry repository list | grep "$(echo $IMAGE_NAME)")" ]; then doctl registry repository delete-manifest $(echo $IMAGE_NAME) $(doctl registry repository list-tags $(echo $IMAGE_NAME) | grep -o "sha.*") --force; else echo "No repository"; fi
4345

4446
- name: Push image to DigitalOcean Container Registry
45-
run: docker push $(echo $REGISTRY)/$(echo $IMAGE_NAME):$(echo $GITHUB_SHA | head -c7)
47+
run: |
48+
# Push both tags to the registry
49+
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
50+
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
4651
4752
deploy:
4853
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)