-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommit_database.sh
More file actions
executable file
·62 lines (49 loc) · 1.71 KB
/
commit_database.sh
File metadata and controls
executable file
·62 lines (49 loc) · 1.71 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
#!/bin/bash
set -e # Exit immediately if a command exits with a non-zero status
# Function to handle errors
handle_error() {
echo "Error: $1"
exit 1
}
# Change to the repository directory
if ! cd /home/austin/development/lean/sorry-index/sorry-db-data-test; then
handle_error "Failed to change to repository directory"
fi
# Get current timestamp
CURRENT_TIME=$(date "+%Y-%m-%d_%H:%M:%S")
LOG_FILE="${CURRENT_TIME}_logs"
echo "Updating database..."
# Run the Docker container with the mounted volume to update databse
docker run \
--mount type=bind,source=/home/austin/development/lean/sorry-index/sorry-db-data-test,target=/data \
sorrydb:latest \
poetry run update_db --database-file /data/sorry_database.json --stats-file /data/update_database_stats.json --log-file "/data/logs/${LOG_FILE}"
# Get current timestamp
CURRENT_TIME=$(date "+%Y-%m-%d %H:%M:%S")
echo "Staging changes..."
# Add all changes
if ! git add .; then
handle_error "Failed to stage changes"
fi
# Check if there are changes to commit
if ! git diff --staged --quiet; then
echo "Committing changes..."
# Commit with timestamp in message
if ! git commit -m "Updating SorryDB at ${CURRENT_TIME}"; then
handle_error "Failed to commit changes"
fi
echo "Creating tag with today's date..."
# Create a tag with today's date
TAG_DATE=$(date "+%Y-%m-%d")
if ! git tag -a "${TAG_DATE}" -m "Database update on ${CURRENT_TIME}"; then
handle_error "Failed to create tag"
fi
echo "Pushing changes and tags..."
# Push changes and tags
if ! git push && git push --tags; then
handle_error "Failed to push changes and tags"
fi
echo "Successfully updated, committed, tagged, and pushed changes"
else
echo "No changes to commit"
fi