-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathpush_to_ghcr.sh
More file actions
executable file
·74 lines (58 loc) · 1.94 KB
/
push_to_ghcr.sh
File metadata and controls
executable file
·74 lines (58 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# Script to build and push markitdown-api to GitHub Container Registry
set -e # Exit on error
GITHUB_USERNAME="dezoito"
IMAGE_NAME="markitdown-api"
# Get MarkItDown version from requirements.txt
echo "Reading MarkItDown version from requirements.txt..."
MARKITDOWN_VERSION=$(grep "^markitdown" requirements.txt | sed 's/.*==\([0-9.]*\).*/\1/')
if [ -z "$MARKITDOWN_VERSION" ]; then
echo "Error: Could not extract MarkItDown version from requirements.txt"
exit 1
fi
echo "MarkItDown version: $MARKITDOWN_VERSION"
echo ""
# Prompt for GitHub credentials
echo "GitHub Container Registry Login"
read -p "GitHub Username: " GH_USER
read -sp "GitHub Personal Access Token (with write:packages scope): " GH_TOKEN
echo ""
echo ""
# Login to GitHub Container Registry
echo "Logging in to ghcr.io..."
echo "$GH_TOKEN" | docker login ghcr.io -u "$GH_USER" --password-stdin
if [ $? -ne 0 ]; then
echo "Login failed"
exit 1
fi
echo "Login successful"
echo ""
# Build and tag the image
echo "Building Docker image..."
docker build -t ghcr.io/$GITHUB_USERNAME/$IMAGE_NAME:latest \
-t ghcr.io/$GITHUB_USERNAME/$IMAGE_NAME:$MARKITDOWN_VERSION .
if [ $? -ne 0 ]; then
echo "Build failed"
exit 1
fi
echo "Build successful"
echo ""
# Push both tags
echo "Pushing images to ghcr.io..."
echo " - ghcr.io/$GITHUB_USERNAME/$IMAGE_NAME:latest"
echo " - ghcr.io/$GITHUB_USERNAME/$IMAGE_NAME:$MARKITDOWN_VERSION"
docker push ghcr.io/$GITHUB_USERNAME/$IMAGE_NAME:latest
docker push ghcr.io/$GITHUB_USERNAME/$IMAGE_NAME:$MARKITDOWN_VERSION
if [ $? -ne 0 ]; then
echo "Push failed"
exit 1
fi
echo ""
echo "Successfully pushed images!"
echo ""
echo "Images available at:"
echo " ghcr.io/$GITHUB_USERNAME/$IMAGE_NAME:latest"
echo " ghcr.io/$GITHUB_USERNAME/$IMAGE_NAME:$MARKITDOWN_VERSION"
echo ""
echo "To make the package public, visit:"
echo " https://github.com/users/$GITHUB_USERNAME/packages/container/$IMAGE_NAME/settings"