diff --git a/.ci/create-pr.sh b/.ci/create-pr.sh index 8bfbe5b..e4947cd 100755 --- a/.ci/create-pr.sh +++ b/.ci/create-pr.sh @@ -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 diff --git a/.ci/on-schedule.sh b/.ci/on-schedule.sh index b0826f7..a4f93ed 100755 --- a/.ci/on-schedule.sh +++ b/.ci/on-schedule.sh @@ -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 @@ -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 diff --git a/.ci/update-template.sh b/.ci/update-template.sh index 03165f8..7d01117 100755 --- a/.ci/update-template.sh +++ b/.ci/update-template.sh @@ -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" \ @@ -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