Skip to content

Commit

Permalink
chore(ci): Update CI from template [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
GitLab CI committed Feb 13, 2024
1 parent 7111cc5 commit e7976be
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .ci/create-pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ function manage_branch() {
# Not up to date
git reset --hard "origin/$target_branch"
git checkout stash -- "$pkgbase"
git commit -m "chore($1): PKGBUILD modified [deploy $pkgbase]"
git commit -m "chore($1): PKGBUILD modified"
git push --force-with-lease origin "$CHANGE_BRANCH"
fi
else
# Branch does not exist, let's create it
git switch -C "$branch" "origin/$target_branch"
git checkout stash -- "$pkgbase"
git commit -m "chore($1): PKGBUILD modified [deploy $pkgbase]"
git commit -m "chore($1): PKGBUILD modified"
git push --force-with-lease origin "$CHANGE_BRANCH"
fi
git stash drop
Expand Down
4 changes: 3 additions & 1 deletion .ci/on-schedule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ for package in "${PACKAGES[@]}"; do
git add .
if [ "$COMMIT" == "false" ]; then
COMMIT=true
git commit -m "chore(packages): update packages [skip ci]"
[ -v GITLAB_CI ] && git commit -m "chore(packages): update packages"
[ -v GITHUB_ACTIONS ] && git commit -m "chore(packages): update packages [skip ci]"
else
git commit --amend --no-edit
fi
Expand All @@ -291,5 +292,6 @@ if [ "$COMMIT" = true ]; then
for branch in "${DELETE_BRANCHES[@]}"; do
git_push_args+=(":$branch")
done
[ -v GITLAB_CI ] && git_push_args+=("-o" "ci.skip")
git push --atomic origin HEAD:main +refs/tags/scheduled "${git_push_args[@]}"
fi
28 changes: 19 additions & 9 deletions .ci/update-template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,28 @@ set -x

CURRENT_REV="$(git rev-parse --abbrev-ref HEAD)"

# CI specific stuff
if [ -v GITLAB_CI ]; then
CI_RSYNC_ARGS=("--include" ".gitlab-ci.yml")
CI_COMMIT_MSG=("-m" "chore(ci): update CI from template")
CI_PUSH_ARGS=("-o" "ci.skip")
elif [ -v GITHUB_ACTIONS ]; then
CI_RSYNC_ARGS=("--include" ".github"
"--include" ".github/workflows"
"--include" ".github/workflows/chaotic-on-commit.yml"
"--include" ".github/workflows/chaotic-on-schedule.yml")
CI_COMMIT_MSG=("-m" "chore(ci): update CI from template [skip ci]")
fi

git clone --depth=1 "$TEMPLATE_REPO" "$TMPDIR/template" -b "main"

trap "git reset --hard $CURRENT_REV" ERR

rsync -a --delete --include ".gitlab-ci.yml" \
--exclude ".ci/config" \
# Generic template files
rsync -a --delete --exclude ".ci/config" \
--include ".ci/***" \
--include ".editorconfig" \
--include ".envrc" \
--include ".github" \
--include ".github/workflows" \
--include ".github/workflows/chaotic-on-commit.yml" \
--include ".github/workflows/chaotic-on-schedule.yml" \
--include ".markdownlint.yaml" \
--include ".prettierignore" \
--include ".shellcheckrc" \
Expand All @@ -27,18 +36,19 @@ rsync -a --delete --include ".gitlab-ci.yml" \
--include "flake.lock" \
--include "flake.nix" \
--include "shell.nix" \
"${CI_RSYNC_ARGS[@]}" \
--exclude "*" \
"$TMPDIR/template/" .

if ! git diff --exit-code --quiet; then
git add .
git commit -m "chore(ci): Update CI from template [skip ci]"
git commit "${CI_COMMIT_MSG[@]}"
# Check if the scheduled tag does not exist or scheduled does not point to HEAD. In which case, the scheduled tag will not be pushed
if ! [ "$(git tag -l "scheduled")" ] || [ "$(git rev-parse HEAD^)" != "$(git rev-parse scheduled)" ]; then
git push --atomic origin HEAD:main
git push --atomic origin HEAD:main "${CI_PUSH_ARGS[@]}"
else
git tag -f scheduled
git push --atomic origin HEAD:main +refs/tags/scheduled
git push --atomic origin HEAD:main +refs/tags/scheduled "${CI_PUSH_ARGS[@]}"
fi
exit 0
fi
Expand Down

0 comments on commit e7976be

Please sign in to comment.