Skip to content

Commit 483914a

Browse files
authored
fix(ci): Correct and improve Ubuntu version sync workflow (#14238)
This PR addresses several issues in the `Ubuntu Version Sync` workflow to improve its reliability and clarity. The workflow was previously failing due to a bash syntax error and was incorrectly applying Dockerfile checks to project-specific files. Key changes: - **Corrected Bash Syntax:** Fixed the syntax for associative array iteration in the `run` step, resolving the `Unexpected symbol: ' @'` error. - **Scoped Dockerfile Checks:** The synchronization check for Dockerfiles is now strictly limited to the `infra/` directory. This prevents the workflow from failing on PRs that only modify Dockerfiles within `projects/`. - **Improved Workflow Name:** Renamed the workflow to `Ubuntu Version Sync Check` for better readability in PR status checks, instead of displaying the raw filename.
1 parent 0df8058 commit 483914a

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

.github/workflows/ubuntu_version_sync.yml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@
1414
#
1515
################################################################################
1616

17-
name: 'Ubuntu Version Sync'
17+
name: 'Ubuntu Version Sync Check'
1818

1919
on:
2020
pull_request:
2121
types: [opened, synchronize, reopened]
2222

2323
jobs:
2424
check-sync:
25+
name: Ubuntu File Synchronization Check
2526
runs-on: ubuntu-latest
27+
env:
28+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
29+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
2630
steps:
2731
- name: 'Checkout code'
2832
uses: actions/checkout@v4
@@ -34,7 +38,7 @@ jobs:
3438
run: |
3539
set -e
3640
37-
MODIFIED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }})
41+
MODIFIED_FILES=$(git diff --name-only $BASE_SHA...$HEAD_SHA)
3842
echo "Checking for synchronized file changes..."
3943
echo "Modified files in this PR:"
4044
echo "$MODIFIED_FILES"
@@ -63,27 +67,27 @@ jobs:
6367
VERSIONS=("ubuntu-20-04" "ubuntu-24-04")
6468
6569
# Check Dockerfiles
66-
for legacy_file in "${{!LEGACY_DOCKERFILES[@]}}"; do
67-
if echo "$MODIFIED_FILES" | grep -q "^${legacy_file}$"; then
70+
for legacy_file in "${!LEGACY_DOCKERFILES[@]}"; do
71+
if [[ "${legacy_file}" == infra/* ]] && echo "$MODIFIED_FILES" | grep -q "^${legacy_file}$"; then
6872
echo "Legacy file changed: $legacy_file. Verifying counterparts..."
69-
for version in "${{VERSIONS[@]}}"; do
70-
pattern=${{LEGACY_DOCKERFILES[$legacy_file]}}
71-
versioned_file="${{pattern/{{version}}/$version}}"
72-
if ! echo "$MODIFIED_FILES" | grep -q "^${{versioned_file}}$"; then
73+
for version in "${VERSIONS[@]}"; do
74+
pattern="${LEGACY_DOCKERFILES[$legacy_file]}"
75+
versioned_file="${pattern/\{version\}/$version}"
76+
if ! echo "$MODIFIED_FILES" | grep -q "^${versioned_file}$"; then
7377
ERRORS+="\n- Legacy file '${legacy_file}' was changed, but its counterpart '${versioned_file}' was not."
7478
fi
7579
done
7680
fi
7781
done
7882
7983
# Check Scripts
80-
for legacy_file in "${{!LEGACY_SCRIPTS[@]}}"; do
84+
for legacy_file in "${!LEGACY_SCRIPTS[@]}"; do
8185
if echo "$MODIFIED_FILES" | grep -q "^${legacy_file}$"; then
8286
echo "Legacy script changed: $legacy_file. Verifying counterparts..."
83-
for version in "${{VERSIONS[@]}}"; do
84-
pattern=${{LEGACY_SCRIPTS[$legacy_file]}}
85-
versioned_file="${{pattern/{{version}}/$version}}"
86-
if ! echo "$MODIFIED_FILES" | grep -q "^${{versioned_file}}$"; then
87+
for version in "${VERSIONS[@]}"; do
88+
pattern="${LEGACY_SCRIPTS[$legacy_file]}"
89+
versioned_file="${pattern/\{version\}/$version}"
90+
if ! echo "$MODIFIED_FILES" | grep -q "^${versioned_file}$"; then
8791
ERRORS+="\n- Legacy script '${legacy_file}' was changed, but its counterpart '${versioned_file}' was not."
8892
fi
8993
done

0 commit comments

Comments
 (0)