Compare commits

...

14 Commits

Author SHA1 Message Date
0d3931d738 Fix cronjobs to use BASH for RANDOM variable. 2025-10-19 21:41:59 -07:00
7c93f25a5d Add output for why dev branch shows up twice during load-prod. 2025-10-15 06:45:49 -07:00
8445b64d6b Check if the dev branch exists before moving to it. 2025-10-15 06:42:16 -07:00
8dfb3fe2a6 Change rollback aliases to only go down 1 layer. Add reset aliases for going all the way back to main. 2025-10-15 06:38:50 -07:00
5b749d2100 Fix failed branch switch. Hardcode to dev! 2025-10-15 06:35:02 -07:00
57ca267aa5 Add back the display of the current local branch we're on. Add newlines for readability. 2025-10-15 06:32:28 -07:00
2ca308c287 Re-do changes lost between branch pointing. 2025-10-15 06:28:38 -07:00
40ee72b587 Only continue each commnd if they are successful. 2025-10-15 06:15:13 -07:00
13bc98d7ef Further enhancments to load-branch. Better output and branch choices. 2025-10-15 06:06:05 -07:00
d916637798 Complete the conditional branches. 2025-10-15 05:53:48 -07:00
71d236d0ba Add aliases to roll branches back to main, AKA the last official pull request. 2025-10-15 05:48:18 -07:00
d81c424878 Allow using load-prod and load-stage with any branch, and default to dev if nothing is provided. 2025-10-15 05:47:01 -07:00
73e527640f Add heads back onto the ls-remote command. 2025-10-15 05:41:12 -07:00
aa3075a9fc Do not do switch back to sender if did not switch to receiver. 2025-10-15 05:33:17 -07:00
2 changed files with 60 additions and 13 deletions

View File

@@ -564,12 +564,15 @@
echo -e "\n*** `basename $project` ***"
cd $project
if [[ -d .git ]]; then
git ls-remote --exit-code origin dev
git ls-remote --exit-code --heads origin dev
dev_exists="$?"
if [[ "$dev_exists" == 0 ]]; then
git switch dev
else
elif [[ "$dev_exists" == 2 ]]; then
git switch main
else
echo "ERROR: Unknown status for dev_exists, '$dev_exists'."
continue
fi
git pull
git push
@@ -893,19 +896,63 @@
function load-branch {
rcvr="$1" # branch which we want to modify
base="$2" # branch with the changes we want
if [[ "$1" == main ]]; then
echo "Are you nuts, fool!? Not main! Do it manually!"
if [[ "$rcvr" == "main" ]]; then
echo "*** ERROR: Are you nuts, fool!? Not main! Do it manually! ***"
exit 1
fi
git switch "$base"
git branch -f "$rcvr" "$base"
#git switch "$rcvr"
git push --force --set-upstream origin "$rcvr"
git switch "$base"
if [[ -z "$base" ]]; then
if [[ "$rcvr" == "prod" ]]; then
base="stage"
elif [[ "$rcvr" == "stage" ]]; then
base="dev"
else
echo "* Unsure which branch to use for '$rcvr'. Please specify."
exit 1
fi
echo "* Base was not specified, using '$base' for '$rcvr'."
else
echo "* Requested pointing '$rcvr' branch to '$base'."
fi
echo -e "\n* Ensuring we are on base branch '$base'." &&
git switch "$base" &&
echo -e "\n* Changing pointer for '$rcvr' to '$base'." &&
git branch -f "$rcvr" "$base" &&
#echo -e "\n* Switching to branch '$rcvr'." &&
#git switch "$rcvr" &&
echo -e "\n* Forcing push on branch '$rcvr'." &&
git push --force --set-upstream origin "$rcvr" &&
echo -e "\n* Done! Displaying list of remote branches." &&
git ls-remote --heads | sort
if [[ "$base" != "dev" ]]; then
echo -e "\n* Checking if a dev branch exists."
git ls-remote --exit-code --heads origin dev
dev_exists="$?"
if [[ "$dev_exists" == 0 ]]; then
echo -e "\n* Switching back to dev."
git switch dev
elif [[ "$dev_exists" == 2 ]]; then
echo -e "\n* Switching back to main."
git switch main
else
echo "*** ERROR: Unknown status for dev_exists, '$dev_exists'. ***"
fi
fi
echo -e "\n* Verifying which branch we're on."
git branch
}
alias load-prod="load-branch prod dev"
alias load-stage="load-branch stage dev"
alias load-prod="load-branch prod"
alias load-stage="load-branch stage"
alias rollback-prod="load-branch prod main"
alias rollback-stage="load-branch stage prod"
alias rollback-dev="load-branch dev stage"
alias reset-prod="load-branch prod main"
alias reset-stage="load-branch stage main"
alias reset-dev="load-branch dev main"
- name: General | Account Management | Users | Files | Common Variable
set_fact:

View File

@@ -12,7 +12,7 @@
user: ansible
name: "Ansible Sync"
minute: "*/30"
job: "sleep $(( $RANDOM / 20 )); sudo {{ ansible_pull_exec.stdout }} -v -o -U {{ git_repo_http }} --checkout {{ branch }}"
job: "bash -c 'sleep $(( $RANDOM / 20 )); sudo {{ ansible_pull_exec.stdout }} -v -o -U {{ git_repo_http }} --checkout {{ branch }}'"
state: present
disabled: "{{ 'yes' if no_telem else 'no' }}"
@@ -21,6 +21,6 @@
user: ansible
name: "Ansible Weekly Forced Sync"
special_time: daily
job: "sleep $(( $RANDOM / 1 )); sudo {{ ansible_pull_exec.stdout }} -v -U {{ git_repo_http }} --checkout {{ branch }}"
job: "bash -c 'sleep $(( $RANDOM / 1 )); sudo {{ ansible_pull_exec.stdout }} -v -U {{ git_repo_http }} --checkout {{ branch }}'"
state: present
disabled: "{{ 'yes' if no_telem else 'no' }}"