mirror of
https://github.com/Snigdha-OS/snigdhaos-docker.git
synced 2025-09-21 15:34:56 +02:00
🐛 fix: verify docker image first
This commit is contained in:
14
.github/workflows/snigdhaos-docker.yml
vendored
14
.github/workflows/snigdhaos-docker.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
|||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# Set up QEMU for multi-architecture builds (optional, now removed arm64)
|
# Set up QEMU for multi-architecture builds
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
@@ -43,6 +43,7 @@ jobs:
|
|||||||
|
|
||||||
# Build and push Docker image (only for amd64 platform now)
|
# Build and push Docker image (only for amd64 platform now)
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
|
id: build
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
context: ./snigdhaos # Ensure the Dockerfile is inside the snigdhaos directory
|
context: ./snigdhaos # Ensure the Dockerfile is inside the snigdhaos directory
|
||||||
@@ -52,8 +53,9 @@ jobs:
|
|||||||
cache-to: type=inline # Use inline caching
|
cache-to: type=inline # Use inline caching
|
||||||
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/snigdhaos:latest # Use cached layers from Docker Hub
|
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/snigdhaos:latest # Use cached layers from Docker Hub
|
||||||
|
|
||||||
# Tag Docker image with version based on the latest Git tag
|
# Check if build succeeded and tag Docker image with version based on the latest Git tag
|
||||||
- name: Tag Docker image with version
|
- name: Tag Docker image with version
|
||||||
|
if: success() # Only proceed if the build was successful
|
||||||
run: |
|
run: |
|
||||||
VERSION=$(git tag -l | tail -n 1 || echo "latest") # Get the latest tag or fallback to "latest"
|
VERSION=$(git tag -l | tail -n 1 || echo "latest") # Get the latest tag or fallback to "latest"
|
||||||
|
|
||||||
@@ -62,6 +64,12 @@ jobs:
|
|||||||
VERSION="latest"
|
VERSION="latest"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Tag and push the image
|
# Verify if the image exists before tagging
|
||||||
|
if docker image inspect ${{ secrets.DOCKERHUB_USERNAME }}/snigdhaos:latest > /dev/null 2>&1; then
|
||||||
|
echo "Image exists, tagging with version: $VERSION"
|
||||||
docker tag ${{ secrets.DOCKERHUB_USERNAME }}/snigdhaos:latest ${{ secrets.DOCKERHUB_USERNAME }}/snigdhaos:${VERSION}
|
docker tag ${{ secrets.DOCKERHUB_USERNAME }}/snigdhaos:latest ${{ secrets.DOCKERHUB_USERNAME }}/snigdhaos:${VERSION}
|
||||||
docker push ${{ secrets.DOCKERHUB_USERNAME }}/snigdhaos:${VERSION}
|
docker push ${{ secrets.DOCKERHUB_USERNAME }}/snigdhaos:${VERSION}
|
||||||
|
else
|
||||||
|
echo "Docker image not found, skipping tag and push."
|
||||||
|
exit 1 # Fail the step if the image does not exist
|
||||||
|
fi
|
||||||
|
Reference in New Issue
Block a user