-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
44 lines (36 loc) · 1.36 KB
/
docker-entrypoint.sh
File metadata and controls
44 lines (36 loc) · 1.36 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
#!/bin/bash
set -e
echo "Setting up git configuration..."
if [ -n "$GIT_USERNAME" ]; then
git config --global user.name "$GIT_USERNAME"
echo "Git username set to: $GIT_USERNAME"
else
echo "Warning: GIT_USERNAME not set"
fi
if [ -n "$GIT_EMAIL" ]; then
git config --global user.email "$GIT_EMAIL"
echo "Git email set to: $GIT_EMAIL"
else
echo "Warning: GIT_EMAIL not set"
fi
if [ -n "$GITHUB_REPOSITORY" ] && [ -n "$GITHUB_TOKEN" ]; then
WORKSPACE_DIR="/config/workspace"
if [ -d "$WORKSPACE_DIR" ]; then
if [ -z "$(ls -A $WORKSPACE_DIR)" ]; then
echo "Workspace is empty, cloning repository..."
git clone "https://oauth2:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "$WORKSPACE_DIR"
cd "$WORKSPACE_DIR"
git remote set-url origin "https://${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
chown -R abc:abc "$WORKSPACE_DIR"
echo "Repository cloned successfully"
else
echo "Workspace is not empty, skipping clone"
cd "$WORKSPACE_DIR"
git remote set-url origin "https://${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" 2>/dev/null || true
fi
else
echo "Workspace directory does not exist, skipping clone"
fi
rm -f "$WORKSPACE_DIR/.git/index.lock" 2>/dev/null || true
fi
exec /init