fix: CI don't configure git globally
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
parent
4349159fef
commit
12f1dd4244
2 changed files with 41 additions and 4 deletions
5
Makefile
5
Makefile
|
@ -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"; \
|
then echo "Only call from within CI. Will re-write your local Git configuration. To override, set export CI=woodpecker"; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
fi
|
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 --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
|
./scripts/ci.sh --clean
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -69,8 +69,10 @@ clean() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# $1: branch name
|
# $1: branch name
|
||||||
# $2: directory containing build assets
|
# $2: directory containing build assets
|
||||||
|
# $3: Author in <author-name author@example.com> format
|
||||||
write_to_branch() {
|
write_to_branch() {
|
||||||
readonly PROJECT_ROOT=$(pwd)
|
readonly PROJECT_ROOT=$(pwd)
|
||||||
cd $PROJECT_ROOT
|
cd $PROJECT_ROOT
|
||||||
|
@ -87,6 +89,8 @@ write_to_branch() {
|
||||||
git fetch origin $1
|
git fetch origin $1
|
||||||
git switch $1
|
git switch $1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
cd ..
|
||||||
git rm -rf .
|
git rm -rf .
|
||||||
/bin/rm -rf *
|
/bin/rm -rf *
|
||||||
cp -r $tmp_dir/* .
|
cp -r $tmp_dir/* .
|
||||||
|
@ -95,6 +99,40 @@ write_to_branch() {
|
||||||
then
|
then
|
||||||
echo "[*] Repository has changed, committing changes"
|
echo "[*] Repository has changed, committing changes"
|
||||||
git commit \
|
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)"
|
--message="new deploy: $(date --iso-8601=seconds)"
|
||||||
fi
|
fi
|
||||||
git checkout $original_branch
|
git checkout $original_branch
|
||||||
|
@ -144,7 +182,7 @@ then
|
||||||
help
|
help
|
||||||
exit -1
|
exit -1
|
||||||
fi
|
fi
|
||||||
write_to_branch $2 $3
|
write_to_branch $2 $3 $4
|
||||||
deploy $2
|
deploy $2
|
||||||
clean
|
clean
|
||||||
elif match_arg $1 '-h' '--help'
|
elif match_arg $1 '-h' '--help'
|
||||||
|
|
Loading…
Reference in a new issue