Skip to content

Commit 5eea729

Browse files
authored
Merge pull request #62 from snickerjp/feat-update-mysql-shell-and-workflows
fix: update workflow file handling and PR instructions for manual upd…
2 parents 1929f21 + 002e05c commit 5eea729

File tree

3 files changed

+64
-37
lines changed

3 files changed

+64
-37
lines changed

.github/check-new-release/scripts/post-message.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ if [[ "$DRY_RUN" != "true" ]]; then
77
echo "::group::PR Creation Completed"
88
echo "✅ PR for MySQL Shell version update has been created."
99
echo ""
10-
echo "Workflow files have been automatically updated, but please verify them."
11-
echo "If automatic updates failed, you can update manually using the following steps:"
10+
echo "⚠️ For security reasons, workflow files were NOT automatically updated."
11+
echo "Please check the PR description for required manual workflow file updates."
1212
echo ""
1313
echo "::endgroup::"
1414

15-
echo "::group::Workflow File Update Procedure (Backup)"
15+
echo "::group::Workflow File Update Procedure"
1616
echo "1. Checkout the PR branch locally:"
1717
echo " git fetch origin $BRANCH_NAME && git checkout $BRANCH_NAME"
1818
echo ""

.github/check-new-release/scripts/update.sh

Lines changed: 60 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ fi
2828
PR_TEMPLATE=$(cat .github/check-new-release/templates/pr.md)
2929
PR_BODY=""
3030

31+
# Initialize workflow update status flag
32+
WORKFLOW_UPDATED="false"
33+
3134
# Version update function
3235
update_version() {
3336
local type=$1
@@ -113,48 +116,54 @@ update_version() {
113116
fi
114117
fi
115118

116-
# Automatically update workflow files
119+
# Check workflow files for potential updates (but don't modify)
117120
local workflow_files=$(find .github/workflows -name "docker-*.yml" 2>/dev/null || echo "")
118121
if [[ -n "$workflow_files" ]]; then
119-
echo "Automatically updating workflow files..."
122+
echo "Checking workflow files for necessary updates (will not modify them)..."
120123

121124
local version_pattern="version: ${major_version}\\.x"
122125
local version_replace="version: ${short_version}"
123126

124-
if [[ "$DRY_RUN" != "true" ]]; then
125-
# Execute for each file
126-
for workflow_file in $workflow_files; do
127-
if grep -q "$version_pattern" "$workflow_file"; then
128-
echo "Updating: $workflow_file"
129-
sed -i "s/$version_pattern/$version_replace/g" "$workflow_file"
130-
if [ $? -ne 0 ]; then
131-
echo "::warning::Failed to update version in $workflow_file"
132-
echo "Failed to update workflow file $workflow_file but will continue with the process."
133-
fi
134-
else
135-
echo "::info::No matching pattern found, no update needed: $workflow_file"
136-
fi
137-
done
138-
else
139-
echo "dry run: Files to be updated:"
140-
for workflow_file in $workflow_files; do
141-
if grep -q "$version_pattern" "$workflow_file"; then
142-
echo "dry run: Update '$version_pattern' to '$version_replace' in $workflow_file"
143-
echo "dry run: Command to execute: sed -i \"s/$version_pattern/$version_replace/g\" \"$workflow_file\""
144-
fi
145-
done
146-
fi
127+
# Create a section in PR body for workflow file updates
128+
WORKFLOW_INSTRUCTIONS=""
129+
local any_needs_update=false
147130

148-
# Add workflow file update note to PR description
149-
PR_BODY="${PR_BODY} (Workflow files were automatically updated)"
131+
# Check each workflow file
132+
for workflow_file in $workflow_files; do
133+
if grep -q "$version_pattern" "$workflow_file"; then
134+
any_needs_update=true
135+
echo "Found workflow file needing update: $workflow_file"
136+
137+
# Get the line number and context for the PR description
138+
local line_info=$(grep -n "$version_pattern" "$workflow_file")
139+
local line_num=$(echo "$line_info" | cut -d':' -f1)
140+
local line_content=$(echo "$line_info" | cut -d':' -f2-)
141+
142+
# Add to workflow update instructions
143+
WORKFLOW_INSTRUCTIONS="${WORKFLOW_INSTRUCTIONS}
144+
- **$workflow_file** (line $line_num):
145+
- From: \`$line_content\`
146+
- To: \`$(echo "$line_content" | sed "s/$version_pattern/$version_replace/")\`"
147+
else
148+
echo "::info::No matching pattern found, no update needed: $workflow_file"
149+
fi
150+
done
151+
152+
# Set flag if any workflows need updates
153+
if [[ "$any_needs_update" == "true" ]]; then
154+
WORKFLOW_UPDATED="true"
155+
echo "⚠️ Found workflow files that need manual updates (details will be in PR description)"
156+
fi
150157
else
151158
echo "::warning::No workflow files found."
159+
# No files found
160+
echo "⚠️ No workflow files found for checking"
152161
fi
153162

154163
# Add version update details to PR body (formatted)
155164
PR_BODY="${PR_BODY}
156165
157-
### ${type^} Version Update
166+
### $(if [[ "$type" == "lts" ]]; then echo "LTS"; else echo "${type^}"; fi) Version Update
158167
* **${current_version}** → **${new_version}**"
159168

160169
# Success log
@@ -176,12 +185,31 @@ PR_BODY="${PR_BODY}
176185
177186
## Update Content
178187
- Updated version numbers in Dockerfiles
179-
- Updated version references in README.md
180-
- Automatically updated workflow files
188+
- Updated version references in README.md"
189+
190+
# Add workflow update instructions if needed
191+
if [[ "${WORKFLOW_UPDATED:-}" == "true" && -n "${WORKFLOW_INSTRUCTIONS:-}" ]]; then
192+
PR_BODY="${PR_BODY}
193+
194+
## ⚠️ Required Manual Updates for Workflow Files
195+
For security reasons, workflow files cannot be automatically updated by GitHub Actions.
196+
Please manually update the following files:
197+
${WORKFLOW_INSTRUCTIONS}
198+
199+
You can apply these changes by:
200+
1. Checking out the branch: \`git checkout ${BRANCH_NAME}\`
201+
2. Making the changes shown above
202+
3. Committing and pushing: \`git commit -am 'Update workflow versions' && git push\`"
203+
else
204+
PR_BODY="${PR_BODY}
205+
- ✓ No workflow file updates needed"
206+
fi
207+
208+
PR_BODY="${PR_BODY}
181209
182210
## ⚠️ Notes
183-
1. If workflow files were not automatically updated, please update them manually
184-
2. Please verify all file changes before merging"
211+
1. Please verify all file changes before merging
212+
2. Workflow files require manual updates (if any are listed above)"
185213

186214
# Commit and push changes
187215
changed_files=$(git status --porcelain | awk '{print $2}')

.github/check-new-release/templates/pr.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ Automated update for MySQL Shell versions.
88
## Updated Files
99
- Version numbers in Dockerfiles
1010
- Version references in README.md
11-
- Automatic workflow file updates
1211

1312
## ⚠️ Notes
14-
1. If workflow files were not automatically updated, please update them manually
13+
1. For security reasons, workflow files require manual updates (see instructions below if applicable)
1514
2. Please verify all file changes before merging

0 commit comments

Comments
 (0)