fix: CI don't configure git globally
ci/woodpecker/push/woodpecker Pipeline failed Details

This commit is contained in:
Aravinth Manivannan 2023-01-02 22:15:31 +05:30
parent 4349159fef
commit 12f1dd4244
Signed by: realaravinth
GPG Key ID: AD9F0F08E855ED88
2 changed files with 41 additions and 4 deletions

View File

@ -9,10 +9,9 @@ ci-deploy: ## Deploy from CI/CD. Only call from within CI
then echo "Only call from within CI. Will re-write your local Git configuration. To override, set export CI=woodpecker"; \
exit 1; \
fi
git config --global user.email "${CI_COMMIT_AUTHOR_EMAIL}"
git config --global user.name "${CI_COMMIT_AUTHOR}"
./scripts/ci.sh --init "$$GITEA_WRITE_DEPLOY_KEY"
./scripts/ci.sh --deploy librepages dist
./scripts/ci.sh --deploy librepages dist "${CI_COMMIT_AUTHOR} <${CI_COMMIT_AUTHOR_EMAIL}>"
#./scripts/ci.sh --deploy librepages dist
./scripts/ci.sh --clean

View File

@ -69,8 +69,10 @@ clean() {
fi
}
# $1: branch name
# $2: directory containing build assets
# $3: Author in <author-name author@example.com> format
write_to_branch() {
readonly PROJECT_ROOT=$(pwd)
cd $PROJECT_ROOT
@ -87,6 +89,8 @@ write_to_branch() {
git fetch origin $1
git switch $1
fi
cd ..
git rm -rf .
/bin/rm -rf *
cp -r $tmp_dir/* .
@ -95,6 +99,40 @@ write_to_branch() {
then
echo "[*] Repository has changed, committing changes"
git commit \
--author="$3" \
--message="new deploy: $(date --iso-8601=seconds)"
fi
git checkout $original_branch
find
}
# $1: branch name
# $2: directory containing build assets
# $3: Author in <author-name author@example.com> format
write_to_branch() {
original_branch=$(git branch --show-current)
tmp_dir=$(mktemp -d)
cp -r $2/* $tmp_dir
if [[ -z $(git ls-remote --heads origin ${1}) ]]
then
echo "[*] Creating deployment branch $1"
git checkout --orphan $1
else
echo "[*] Deployment branch $1 exists, pulling changes from remote"
git fetch origin $1
git status
git switch $1
fi
git rm -rf .
/bin/rm -rf *
cp -r $tmp_dir/* .
git add --all
if [ $(git status --porcelain | xargs | sed '/^$/d' | wc -l) -gt 0 ];
then
echo "[*] Repository has changed, committing changes"
git commit \
--author="$3" \
--message="new deploy: $(date --iso-8601=seconds)"
fi
git checkout $original_branch
@ -144,7 +182,7 @@ then
help
exit -1
fi
write_to_branch $2 $3
write_to_branch $2 $3 $4
deploy $2
clean
elif match_arg $1 '-h' '--help'