|
3 | 3 |
|
4 | 4 | # Configuration |
5 | 5 | DATA_REPO_URL="${DATA_REPO_URL:-https://github.com/LSX-UniWue/brace-ctf-data.git}" |
6 | | -DATA_BRANCH="${DATA_BRANCH:-main}" |
| 6 | +DATA_REF="${DATA_REF:-${DATA_BRANCH:-main}}" # Support both DATA_REF and legacy DATA_BRANCH |
7 | 7 | DATA_DIR="/home/agent/data" |
8 | 8 | SKIP_DATA_CLONE="${SKIP_DATA_CLONE:-false}" |
9 | 9 |
|
|
26 | 26 | echo "No authentication token found. Assuming public repository." |
27 | 27 | fi |
28 | 28 |
|
29 | | -# If data directory exists and is a git repo, pull latest |
| 29 | +# If data directory exists and is a git repo, update it |
30 | 30 | if [ -d "$DATA_DIR/.git" ]; then |
31 | 31 | echo "📦 Updating existing data repository..." |
32 | 32 | cd "$DATA_DIR" |
33 | | - git fetch origin |
34 | | - git reset --hard "origin/$DATA_BRANCH" |
| 33 | + git fetch origin --tags |
| 34 | + # Check if DATA_REF is a tag or branch |
| 35 | + if git show-ref --tags "refs/tags/$DATA_REF" > /dev/null 2>&1; then |
| 36 | + echo "Checking out tag: $DATA_REF" |
| 37 | + git checkout "tags/$DATA_REF" |
| 38 | + else |
| 39 | + echo "Checking out branch: $DATA_REF" |
| 40 | + git reset --hard "origin/$DATA_REF" |
| 41 | + fi |
35 | 42 | cd /home/agent |
36 | 43 | else |
37 | 44 | # Clone fresh |
38 | 45 | echo "📥 Cloning data repository..." |
39 | 46 | rm -rf "$DATA_DIR" |
40 | | - if ! git clone --depth 1 --branch "$DATA_BRANCH" "$AUTH_DATA_REPO_URL" "$DATA_DIR"; then |
| 47 | + if ! git clone --depth 1 --branch "$DATA_REF" "$AUTH_DATA_REPO_URL" "$DATA_DIR"; then |
41 | 48 | echo "❌ Error: Failed to clone data repository from $AUTH_DATA_REPO_URL" |
42 | | - echo " Please ensure the repository exists and is accessible, and that DATA_REPO_URL and DATA_BRANCH are correct." |
| 49 | + echo " Please ensure the repository exists and is accessible, and that DATA_REPO_URL and DATA_REF are correct." |
43 | 50 | echo " If it's a private repository, ensure GITHUB_TOKEN or an embedded token is provided." |
44 | 51 | exit 1 |
45 | 52 | fi |
46 | 53 | fi |
47 | 54 |
|
| 55 | +# Capture commit information for evaluation tracking |
| 56 | +cd "$DATA_DIR" |
| 57 | +DATA_COMMIT_SHA=$(git rev-parse HEAD) |
| 58 | +DATA_COMMIT_SHORT=$(git rev-parse --short HEAD) |
| 59 | +DATA_COMMIT_DESCRIBE=$(git describe --tags --always 2>/dev/null || echo "$DATA_COMMIT_SHORT") |
| 60 | +DATA_COMMIT_DATE=$(git log -1 --format=%ci) |
| 61 | + |
| 62 | +# Extract repo owner and name from URL for condensed identifier |
| 63 | +REPO_PATH=$(echo "$DATA_REPO_URL" | sed -E 's|.*github\.com[/:]([^/]+/[^/.]+)(\.git)?.*|\1|') |
| 64 | +DATA_VERSION_FULL="${REPO_PATH}@${DATA_COMMIT_DESCRIBE}" |
| 65 | + |
| 66 | +cd /home/agent |
| 67 | + |
| 68 | +# Export as environment variables for the application to use |
| 69 | +export DATA_REPO_URL |
| 70 | +export DATA_COMMIT_SHA |
| 71 | +export DATA_COMMIT_SHORT |
| 72 | +export DATA_COMMIT_DESCRIBE |
| 73 | +export DATA_COMMIT_DATE |
| 74 | +export DATA_VERSION="$DATA_COMMIT_DESCRIBE" |
| 75 | +export DATA_VERSION_FULL |
| 76 | + |
48 | 77 | echo "✅ Data repository ready!" |
| 78 | +echo "📍 Data Version: $DATA_VERSION_FULL" |
| 79 | +echo " Commit SHA: $DATA_COMMIT_SHA" |
| 80 | +echo " Commit Date: $DATA_COMMIT_DATE" |
49 | 81 | echo "" |
50 | 82 |
|
51 | 83 | # Execute the server with provided arguments |
|
0 commit comments