fix: handle existing git tags and use DOCKER_LOGIN/DOCKER_PASSWORD secrets
This commit is contained in:
@@ -62,19 +62,35 @@ jobs:
|
||||
|
||||
- name: Create git tag for release
|
||||
run: |
|
||||
git tag -a "v${{ steps.version.outputs.version }}" -m "Release v${{ steps.version.outputs.version }}"
|
||||
git push origin "v${{ steps.version.outputs.version }}"
|
||||
TAG_NAME="v${{ steps.version.outputs.version }}"
|
||||
# Check if tag already exists
|
||||
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
|
||||
echo "Tag $TAG_NAME already exists, skipping creation"
|
||||
else
|
||||
echo "Creating tag $TAG_NAME"
|
||||
git tag -a "$TAG_NAME" -m "Release $TAG_NAME"
|
||||
fi
|
||||
# Always try to push (in case tag exists locally but not remotely)
|
||||
git push origin "$TAG_NAME" || echo "Tag push failed (may already exist remotely)"
|
||||
|
||||
- name: Push Docker images
|
||||
run: |
|
||||
echo "Pushing to ${{ env.REGISTRY }}..."
|
||||
# Check if we can authenticate to the registry
|
||||
if docker login ${{ env.REGISTRY }} -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} 2>/dev/null; then
|
||||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
|
||||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||
echo "Successfully pushed images to ${{ env.REGISTRY }}"
|
||||
# Check if we can authenticate to the registry using DOCKER_LOGIN and DOCKER_PASSWORD secrets
|
||||
if [ -n "${{ secrets.DOCKER_LOGIN }}" ] && [ -n "${{ secrets.DOCKER_PASSWORD }}" ]; then
|
||||
if docker login ${{ env.REGISTRY }} -u ${{ secrets.DOCKER_LOGIN }} -p ${{ secrets.DOCKER_PASSWORD }} 2>/dev/null; then
|
||||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
|
||||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||
echo "Successfully pushed images to ${{ env.REGISTRY }}"
|
||||
else
|
||||
echo "Warning: Docker login failed with provided credentials"
|
||||
echo "Images built locally but not pushed to registry"
|
||||
echo "Manual push required:"
|
||||
echo " docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}"
|
||||
echo " docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
|
||||
fi
|
||||
else
|
||||
echo "Warning: Could not authenticate to ${{ env.REGISTRY }}"
|
||||
echo "Warning: DOCKER_LOGIN or DOCKER_PASSWORD secrets not configured"
|
||||
echo "Images built locally but not pushed to registry"
|
||||
echo "Manual push required:"
|
||||
echo " docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}"
|
||||
|
||||
Reference in New Issue
Block a user