|
8 | 8 | terraform-github-teams \ |
9 | 9 | terraform-github-organization \ |
10 | 10 | terraform-googleworkspace-users-groups-automation \ |
11 | | - terraform-postgres-automation \ |
| 11 | + terraform-postgres-config-dbs-users-roles \ |
12 | 12 | terraform-secrets-helper \ |
13 | 13 | terraform-spacelift-automation \ |
14 | 14 | terraform-spacelift-aws-integrations \ |
@@ -67,19 +67,41 @@ tasks: |
67 | 67 |
|
68 | 68 | vars: |
69 | 69 | MODULES: "{{if .CLI_ARGS}}{{.CLI_ARGS}}{{else}}{{.DEFAULT_MODULES}}{{end}}" |
| 70 | + DELETE_EXISTING_SYNC_BRANCH: "{{.DELETE_EXISTING_SYNC_BRANCH | default false}}" |
70 | 71 | cmds: |
71 | 72 | - | |
72 | 73 | # Convert newlines to spaces and remove backslashes |
73 | 74 | modules=$(echo "{{.MODULES}}" | tr '\n' ' ' | sed 's/\\//g') |
74 | 75 | for module in $modules |
75 | 76 | do |
76 | | - echo "🚀 Processing ../$module..." |
| 77 | + echo -e "\n\n🚀 Processing ---------------- $module \n" |
| 78 | + if [ ! -d ../$module ]; then |
| 79 | + echo "🧲 Cloning repository..." |
| 80 | + git clone "[email protected]:masterpointio/$module.git" ../$module |
| 81 | + fi |
77 | 82 | cd ../$module |
78 | | - echo "⬇️ Pulling main branch..." |
| 83 | +
|
| 84 | + echo "⬇️ Pulling main branch..." |
79 | 85 | git checkout main |
80 | 86 | git pull origin main |
81 | | - echo "🔄 Creating sync branch..." |
82 | | - git checkout -b {{.SYNC_BRANCH}} |
| 87 | +
|
| 88 | + echo "🔄 Creating sync branch ..." |
| 89 | +
|
| 90 | + # If branch exists and delete option is turned off - skip creation |
| 91 | + if git branch --list "{{.SYNC_BRANCH}}" | grep -q "{{.SYNC_BRANCH}}" && [ "{{.DELETE_EXISTING_SYNC_BRANCH}}" = "false" ]; then |
| 92 | + echo "⏭️ Branch {{.SYNC_BRANCH}} already exists, skipping creation." |
| 93 | +
|
| 94 | + # If branch exists and delete option is turned on - delete and create new branch |
| 95 | + elif git branch --list "{{.SYNC_BRANCH}}" | grep -q "{{.SYNC_BRANCH}}" && [ "{{.DELETE_EXISTING_SYNC_BRANCH}}" = "true" ]; then |
| 96 | + echo "⏭️ Branch {{.SYNC_BRANCH}} already exists, deleting it." |
| 97 | + git branch -D {{.SYNC_BRANCH}} |
| 98 | + git checkout -b {{.SYNC_BRANCH}} |
| 99 | +
|
| 100 | + # If branch does not exist - create new branch |
| 101 | + else |
| 102 | + git checkout -b {{.SYNC_BRANCH}} |
| 103 | + fi |
| 104 | +
|
83 | 105 | cd - |
84 | 106 | done |
85 | 107 |
|
@@ -138,6 +160,7 @@ tasks: |
138 | 160 |
|
139 | 161 | vars: |
140 | 162 | MODULES: "{{if .CLI_ARGS}}{{.CLI_ARGS}}{{else}}{{.DEFAULT_MODULES}}{{end}}" |
| 163 | + DELETE_EXISTING_SYNC_BRANCH: "{{.DELETE_EXISTING_SYNC_BRANCH | default false}}" |
141 | 164 | cmds: |
142 | 165 | - task: setup-template |
143 | 166 | - task: pull-and-branch |
|
0 commit comments