Created
November 14, 2024 09:20
-
-
Save fishyer/264389ae2a055a123fd52a256f70b505 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "✅pre-commit hook start at $(date)" | |
start_time=$(date +%s) | |
# 添加环境变量 | |
source .env | |
echo "👁️build_version: $build_version" | |
echo "👁️build_time: $build_time" | |
# 将环境变量的第三位加1 | |
build_version=$(echo $build_version | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g') | |
echo "📝new build_version: $build_version" | |
gsed -i "s/^build_version=.*/build_version=$build_version/" .env | |
build_time=$(date +"%Y-%m-%d %H:%M:%S") | |
echo "📝new build_time: $build_time" | |
gsed -i 's/^build_time=.*/build_time="'"$build_time"'"/' .env | |
# 添加到git | |
git add .env | |
echo "🎉pre-commit hook end at $(date) elapsed $(($(date +%s) - $start_time)) seconds" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment