From edb647e9efeed2b6711e765c702ceabcb0ccb658 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 16 Jan 2026 15:45:46 +0000 Subject: [PATCH 1/2] Initial plan From 7f6d8d64cfea06f1924ccdde268a494ba9f48547 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 16 Jan 2026 15:50:55 +0000 Subject: [PATCH 2/2] IONOS(build): address code review feedback - reduce duplication and improve maintainability Co-authored-by: printminion-co <145785698+printminion-co@users.noreply.github.com> --- .github/actions/get-job-data/action.yml | 11 ++++++++-- .github/scripts/detect-app-cache.sh | 6 ++++-- .github/workflows/build-artifact.yml | 27 ++++++++++++++++++------- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/.github/actions/get-job-data/action.yml b/.github/actions/get-job-data/action.yml index 1bbb44fcb02e0..929b8785fb174 100644 --- a/.github/actions/get-job-data/action.yml +++ b/.github/actions/get-job-data/action.yml @@ -26,6 +26,15 @@ runs: run: | # Fetch the numeric job ID from GitHub API CURL_ERROR_FILE=$(mktemp) + + # Ensure temporary file cleanup on exit + cleanup() { + if [ -n "$CURL_ERROR_FILE" ] && [ -f "$CURL_ERROR_FILE" ]; then + rm -f "$CURL_ERROR_FILE" + fi + } + trap cleanup EXIT + API_RESPONSE=$(curl -sS -w "\n%{http_code}" \ -H "Authorization: Bearer ${{ inputs.github-token }}" \ -H "Accept: application/vnd.github+json" \ @@ -38,12 +47,10 @@ runs: echo "curl error output:" cat "$CURL_ERROR_FILE" fi - rm -f "$CURL_ERROR_FILE" echo "job_html_url=" >> "$GITHUB_OUTPUT" exit 0 fi - rm -f "$CURL_ERROR_FILE" HTTP_CODE=$(echo "$API_RESPONSE" | tail -n1) RESPONSE_BODY=$(echo "$API_RESPONSE" | sed '$d') diff --git a/.github/scripts/detect-app-cache.sh b/.github/scripts/detect-app-cache.sh index 8e989a8523d2f..2e7a10514b101 100644 --- a/.github/scripts/detect-app-cache.sh +++ b/.github/scripts/detect-app-cache.sh @@ -117,9 +117,11 @@ echo "|-----|-----|-----------|--------|" >> "$GITHUB_STEP_SUMMARY" # Convert comma-separated apps list to array for easier checking if [ -n "$APPS_TO_REBUILD" ]; then IFS=',' read -ra REBUILD_APPS_ARRAY <<< "$APPS_TO_REBUILD" - # Trim whitespace from each app name + # Trim whitespace from each app name using bash parameter expansion for i in "${!REBUILD_APPS_ARRAY[@]}"; do - REBUILD_APPS_ARRAY[$i]=$(echo "${REBUILD_APPS_ARRAY[$i]}" | xargs) + # Remove leading and trailing whitespace + REBUILD_APPS_ARRAY[$i]="${REBUILD_APPS_ARRAY[$i]#"${REBUILD_APPS_ARRAY[$i]%%[![:space:]]*}"}" + REBUILD_APPS_ARRAY[$i]="${REBUILD_APPS_ARRAY[$i]%"${REBUILD_APPS_ARRAY[$i]##*[![:space:]]}"}" done else REBUILD_APPS_ARRAY=() diff --git a/.github/workflows/build-artifact.yml b/.github/workflows/build-artifact.yml index 29e26807ff40a..6d7ffc3685958 100644 --- a/.github/workflows/build-artifact.yml +++ b/.github/workflows/build-artifact.yml @@ -76,7 +76,16 @@ jobs: apps_sha_map: ${{ steps.detect.outputs.apps_sha_map }} has_apps_to_build: ${{ steps.detect.outputs.has_apps_to_build }} has_apps_to_restore: ${{ steps.detect.outputs.has_apps_to_restore }} + effective_cache_version: ${{ steps.compute_cache_version.outputs.effective_cache_version }} steps: + - name: Compute effective cache version + id: compute_cache_version + run: | + # Compute cache version with optional suffix to create a single source of truth + EFFECTIVE_VERSION="${{ env.CACHE_VERSION }}${{ github.event.inputs.cache_version_suffix && format('-{0}', github.event.inputs.cache_version_suffix) || '' }}" + echo "effective_cache_version=$EFFECTIVE_VERSION" >> "$GITHUB_OUTPUT" + echo "Effective cache version: $EFFECTIVE_VERSION" + - name: Checkout repository uses: actions/checkout@v5 with: @@ -192,7 +201,7 @@ jobs: id: detect env: GH_TOKEN: ${{ github.token }} - CACHE_VERSION: ${{ env.CACHE_VERSION }}${{ github.event.inputs.cache_version_suffix && format('-{0}', github.event.inputs.cache_version_suffix) || '' }} + CACHE_VERSION: ${{ steps.compute_cache_version.outputs.effective_cache_version }} FORCE_REBUILD: ${{ github.event.inputs.force_rebuild || 'false' }} APPS_TO_REBUILD: ${{ github.event.inputs.apps_to_rebuild || '' }} JF_URL: ${{ secrets.JF_ARTIFACTORY_URL }} @@ -304,7 +313,7 @@ jobs: uses: actions/cache/save@v4 with: path: ${{ steps.app-config.outputs.path }} - key: ${{ env.CACHE_VERSION }}${{ github.event.inputs.cache_version_suffix && format('-{0}', github.event.inputs.cache_version_suffix) || '' }}-app-build-${{ matrix.app_info.name }}-${{ matrix.app_info.sha }} + key: ${{ needs.prepare-matrix.outputs.effective_cache_version }}-app-build-${{ matrix.app_info.name }}-${{ matrix.app_info.sha }} # Push to JFrog for ionos-dev branch builds - name: Setup JFrog CLI @@ -336,8 +345,8 @@ jobs: APP_SHA="${{ matrix.app_info.sha }}" APP_PATH="${{ steps.app-config.outputs.path }}" - # Compute effective cache version with suffix - EFFECTIVE_CACHE_VERSION="${{ env.CACHE_VERSION }}${{ github.event.inputs.cache_version_suffix && format('-{0}', github.event.inputs.cache_version_suffix) || '' }}" + # Use precomputed effective cache version + EFFECTIVE_CACHE_VERSION="${{ needs.prepare-matrix.outputs.effective_cache_version }}" echo "=== JFrog Upload Debug Info ===" echo "📦 Packaging $APP_NAME for JFrog upload..." @@ -391,7 +400,9 @@ jobs: JFROG_PROPS_LIST+=("job.html_url=${JOB_URL}") fi - # Join properties into a single semicolon-separated string + # Join properties into a single semicolon-separated string using IFS and array expansion + # This bash technique temporarily sets IFS (Internal Field Separator) to ';' and expands + # the array with [*] which joins elements using the first character of IFS JFROG_PROPS=$(IFS=';'; printf '%s' "${JFROG_PROPS_LIST[*]}") echo "" @@ -778,7 +789,9 @@ jobs: JFROG_PROPS_LIST+=("job.html_url=${JOB_URL}") fi - # Join properties into a single semicolon-separated string + # Join properties into a single semicolon-separated string using IFS and array expansion + # This bash technique temporarily sets IFS (Internal Field Separator) to ';' and expands + # the array with [*] which joins elements using the first character of IFS JFROG_PROPS=$(IFS=';'; printf '%s' "${JFROG_PROPS_LIST[*]}") # Upload with retry logic (3 attempts with 30s delay) @@ -1198,7 +1211,7 @@ jobs: echo "" echo "### Environment Variables" echo "Base CACHE_VERSION: ${{ env.CACHE_VERSION }}" - echo "Effective CACHE_VERSION: ${{ env.CACHE_VERSION }}${{ github.event.inputs.cache_version_suffix && format('-{0}', github.event.inputs.cache_version_suffix) || '' }}" + echo "Effective CACHE_VERSION: ${{ needs.prepare-matrix.outputs.effective_cache_version }}" echo "TARGET_PACKAGE_NAME: ${{ env.TARGET_PACKAGE_NAME }}" echo "ARTIFACTORY_REPOSITORY_SNAPSHOT: ${{ env.ARTIFACTORY_REPOSITORY_SNAPSHOT }}" echo ""