Skip to content

Commit 1929f21

Browse files
authored
Merge pull request #60 from snickerjp/feat-update-mysql-shell-and-workflows
fix: enhance branch name generation logic for MySQL Shell updates
2 parents 98b72f8 + 78646a8 commit 1929f21

File tree

1 file changed

+41
-6
lines changed

1 file changed

+41
-6
lines changed

.github/workflows/check-new-release.yml

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,25 @@ jobs:
195195
INNOVATION_UPDATE_NEEDED: ${{ steps.check_versions.outputs.INNOVATION_UPDATE_NEEDED }}
196196
LTS_UPDATE_NEEDED: ${{ steps.check_versions.outputs.LTS_UPDATE_NEEDED }}
197197
run: |
198-
# Generate branch name at runtime with timestamp
199-
BRANCH_NAME="bot/update-mysql-shell-$(date +%Y%m%d%H%M%S)"
198+
# Generate branch name using version information instead of timestamp
199+
if [[ "$INNOVATION_UPDATE_NEEDED" == "true" && "$LTS_UPDATE_NEEDED" == "true" ]]; then
200+
# Both versions need updating - include both in the branch name
201+
BRANCH_NAME="bot/update-mysql-shell-all-inno${LATEST_INNOVATION}-lts${LATEST_LTS}"
202+
elif [[ "$INNOVATION_UPDATE_NEEDED" == "true" ]]; then
203+
# Only Innovation needs updating
204+
BRANCH_NAME="bot/update-mysql-shell-innovation-${LATEST_INNOVATION}"
205+
elif [[ "$LTS_UPDATE_NEEDED" == "true" ]]; then
206+
# Only LTS needs updating
207+
BRANCH_NAME="bot/update-mysql-shell-lts-${LATEST_LTS}"
208+
else
209+
# Fallback - should not reach here, but just in case
210+
BRANCH_NAME="bot/update-mysql-shell-$(date +%Y%m%d%H%M%S)"
211+
fi
200212
echo "Using branch name: $BRANCH_NAME"
201213
214+
# Export as environment variable for scripts that need it
215+
export BRANCH_NAME
216+
202217
# Set as output for reuse in subsequent steps
203218
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_OUTPUT
204219
@@ -218,7 +233,8 @@ jobs:
218233
else
219234
# If not executable, explicitly use bash
220235
echo "Running update.sh via bash (no execution permissions)"
221-
bash .github/check-new-release/scripts/update.sh
236+
# Pass current environment including BRANCH_NAME to the bash process
237+
bash -c 'set -e; source .github/check-new-release/scripts/update.sh'
222238
# Immediately capture exit status to avoid overwrites
223239
UPDATE_STATUS=$?
224240
fi
@@ -243,13 +259,31 @@ jobs:
243259
# Verify branch name is available from previous step
244260
if [ -z "$BRANCH_NAME" ]; then
245261
echo "::warning::Branch name not available from previous step"
246-
echo "Generating new branch name as fallback"
247-
BRANCH_NAME="bot/update-mysql-shell-$(date +%Y%m%d%H%M%S)"
262+
echo "Generating fallback branch name based on version information"
263+
264+
# Generate branch name using version information even in fallback
265+
if [[ "$INNOVATION_UPDATE_NEEDED" == "true" && "$LTS_UPDATE_NEEDED" == "true" ]]; then
266+
# Both versions need updating
267+
BRANCH_NAME="bot/update-mysql-shell-all-inno${LATEST_INNOVATION}-lts${LATEST_LTS}"
268+
elif [[ "$INNOVATION_UPDATE_NEEDED" == "true" ]]; then
269+
# Only Innovation needs updating
270+
BRANCH_NAME="bot/update-mysql-shell-innovation-${LATEST_INNOVATION}"
271+
elif [[ "$LTS_UPDATE_NEEDED" == "true" ]]; then
272+
# Only LTS needs updating
273+
BRANCH_NAME="bot/update-mysql-shell-lts-${LATEST_LTS}"
274+
else
275+
# Ultimate fallback with timestamp
276+
BRANCH_NAME="bot/update-mysql-shell-fallback-$(date +%Y%m%d%H%M%S)"
277+
fi
278+
248279
echo "Generated fallback branch name: $BRANCH_NAME"
249280
else
250281
echo "Using branch name from previous step: $BRANCH_NAME"
251282
fi
252283
284+
# Export as environment variable for scripts that need it
285+
export BRANCH_NAME
286+
253287
# Verify that post-message script exists before execution
254288
if [ ! -f .github/check-new-release/scripts/post-message.sh ]; then
255289
echo "::error::Script post-message.sh not found"
@@ -266,7 +300,8 @@ jobs:
266300
else
267301
# If not executable, explicitly use bash
268302
echo "Running post-message.sh via bash (no execution permissions)"
269-
bash .github/check-new-release/scripts/post-message.sh
303+
# Pass current environment including BRANCH_NAME to the bash process
304+
bash -c 'set -e; source .github/check-new-release/scripts/post-message.sh'
270305
# Immediately capture exit status to avoid overwrites
271306
POST_MESSAGE_STATUS=$?
272307
fi

0 commit comments

Comments
 (0)