mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-27 15:37:02 +00:00
refactor: remove redundant linux_builds_success logic in docker workflow (#235)
- Remove linux_builds_success output and related variables - Simplify build-docker condition to only check should_build - The should_build check already includes workflow success verification - Reduce code complexity while maintaining the same functionality
This commit is contained in:
@@ -27,10 +27,9 @@
|
|||||||
|
|
||||||
name: Docker Images
|
name: Docker Images
|
||||||
|
|
||||||
# Permissions needed for workflow_run event and GitHub API access
|
# Permissions needed for workflow_run event and Docker registry access
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
actions: read
|
|
||||||
packages: write
|
packages: write
|
||||||
|
|
||||||
on:
|
on:
|
||||||
@@ -78,14 +77,13 @@ jobs:
|
|||||||
short_sha: ${{ steps.check.outputs.short_sha }}
|
short_sha: ${{ steps.check.outputs.short_sha }}
|
||||||
is_prerelease: ${{ steps.check.outputs.is_prerelease }}
|
is_prerelease: ${{ steps.check.outputs.is_prerelease }}
|
||||||
create_latest: ${{ steps.check.outputs.create_latest }}
|
create_latest: ${{ steps.check.outputs.create_latest }}
|
||||||
linux_builds_success: ${{ steps.check.outputs.linux_builds_success }}
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Check build conditions and Linux build status
|
- name: Check build conditions
|
||||||
id: check
|
id: check
|
||||||
run: |
|
run: |
|
||||||
should_build=false
|
should_build=false
|
||||||
@@ -95,51 +93,20 @@ jobs:
|
|||||||
short_sha=""
|
short_sha=""
|
||||||
is_prerelease=false
|
is_prerelease=false
|
||||||
create_latest=false
|
create_latest=false
|
||||||
linux_builds_success=false
|
|
||||||
|
|
||||||
if [[ "${{ github.event_name }}" == "workflow_run" ]]; then
|
if [[ "${{ github.event_name }}" == "workflow_run" ]]; then
|
||||||
# Triggered by build workflow completion
|
# Triggered by build workflow completion
|
||||||
echo "🔗 Triggered by build workflow completion"
|
echo "🔗 Triggered by build workflow completion"
|
||||||
|
|
||||||
# Check if the triggering workflow was successful
|
# Check if the triggering workflow was successful
|
||||||
if [[ "${{ github.event.workflow_run.conclusion }}" != "success" ]]; then
|
# If the workflow succeeded, it means ALL builds (including Linux x86_64 and aarch64) succeeded
|
||||||
echo "❌ Build workflow failed, skipping Docker build"
|
if [[ "${{ github.event.workflow_run.conclusion }}" == "success" ]]; then
|
||||||
exit 0
|
echo "✅ Build workflow succeeded, all builds including Linux are successful"
|
||||||
fi
|
|
||||||
|
|
||||||
# Get workflow run details via GitHub API to check Linux build status
|
|
||||||
echo "🔍 Checking Linux build status from workflow run..."
|
|
||||||
|
|
||||||
# Use GitHub API to get detailed job information
|
|
||||||
WORKFLOW_RUN_ID="${{ github.event.workflow_run.id }}"
|
|
||||||
|
|
||||||
# Get jobs from the workflow run
|
|
||||||
echo "📡 Fetching job details for workflow run: $WORKFLOW_RUN_ID"
|
|
||||||
|
|
||||||
# Check if Linux builds were successful using GitHub API
|
|
||||||
JOBS_RESPONSE=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
|
|
||||||
"https://api.github.com/repos/${{ github.repository }}/actions/runs/$WORKFLOW_RUN_ID/jobs")
|
|
||||||
|
|
||||||
# Extract Linux build job status
|
|
||||||
LINUX_X64_SUCCESS=$(echo "$JOBS_RESPONSE" | jq -r '.jobs[] | select(.name | contains("x86_64-unknown-linux-musl")) | .conclusion')
|
|
||||||
LINUX_ARM64_SUCCESS=$(echo "$JOBS_RESPONSE" | jq -r '.jobs[] | select(.name | contains("aarch64-unknown-linux-musl")) | .conclusion')
|
|
||||||
|
|
||||||
echo "🐧 Linux build status:"
|
|
||||||
echo " x86_64: $LINUX_X64_SUCCESS"
|
|
||||||
echo " aarch64: $LINUX_ARM64_SUCCESS"
|
|
||||||
|
|
||||||
# Only proceed if both Linux builds are successful
|
|
||||||
if [[ "$LINUX_X64_SUCCESS" == "success" ]] && [[ "$LINUX_ARM64_SUCCESS" == "success" ]]; then
|
|
||||||
linux_builds_success=true
|
|
||||||
should_build=true
|
should_build=true
|
||||||
should_push=true
|
should_push=true
|
||||||
echo "✅ Both Linux builds successful, proceeding with Docker build"
|
|
||||||
else
|
else
|
||||||
linux_builds_success=false
|
echo "❌ Build workflow failed (conclusion: ${{ github.event.workflow_run.conclusion }}), skipping Docker build"
|
||||||
should_build=false
|
should_build=false
|
||||||
echo "❌ Linux builds not both successful, skipping Docker build"
|
|
||||||
echo " x86_64 status: $LINUX_X64_SUCCESS"
|
|
||||||
echo " aarch64 status: $LINUX_ARM64_SUCCESS"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Extract version info from commit message or use commit SHA
|
# Extract version info from commit message or use commit SHA
|
||||||
@@ -176,7 +143,6 @@ jobs:
|
|||||||
input_version="${{ github.event.inputs.version }}"
|
input_version="${{ github.event.inputs.version }}"
|
||||||
version="${input_version}"
|
version="${input_version}"
|
||||||
should_push="${{ github.event.inputs.push_images }}"
|
should_push="${{ github.event.inputs.push_images }}"
|
||||||
linux_builds_success=true # Assume true for manual builds
|
|
||||||
should_build=true
|
should_build=true
|
||||||
|
|
||||||
# Get short SHA
|
# Get short SHA
|
||||||
@@ -225,12 +191,6 @@ jobs:
|
|||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Only proceed if Linux builds were successful
|
|
||||||
if [[ "$linux_builds_success" != "true" ]]; then
|
|
||||||
echo "❌ Linux builds not successful, skipping Docker image build"
|
|
||||||
should_build=false
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "should_build=$should_build" >> $GITHUB_OUTPUT
|
echo "should_build=$should_build" >> $GITHUB_OUTPUT
|
||||||
echo "should_push=$should_push" >> $GITHUB_OUTPUT
|
echo "should_push=$should_push" >> $GITHUB_OUTPUT
|
||||||
echo "build_type=$build_type" >> $GITHUB_OUTPUT
|
echo "build_type=$build_type" >> $GITHUB_OUTPUT
|
||||||
@@ -238,7 +198,6 @@ jobs:
|
|||||||
echo "short_sha=$short_sha" >> $GITHUB_OUTPUT
|
echo "short_sha=$short_sha" >> $GITHUB_OUTPUT
|
||||||
echo "is_prerelease=$is_prerelease" >> $GITHUB_OUTPUT
|
echo "is_prerelease=$is_prerelease" >> $GITHUB_OUTPUT
|
||||||
echo "create_latest=$create_latest" >> $GITHUB_OUTPUT
|
echo "create_latest=$create_latest" >> $GITHUB_OUTPUT
|
||||||
echo "linux_builds_success=$linux_builds_success" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
echo "🐳 Docker Build Summary:"
|
echo "🐳 Docker Build Summary:"
|
||||||
echo " - Should build: $should_build"
|
echo " - Should build: $should_build"
|
||||||
@@ -248,16 +207,15 @@ jobs:
|
|||||||
echo " - Short SHA: $short_sha"
|
echo " - Short SHA: $short_sha"
|
||||||
echo " - Is prerelease: $is_prerelease"
|
echo " - Is prerelease: $is_prerelease"
|
||||||
echo " - Create latest: $create_latest"
|
echo " - Create latest: $create_latest"
|
||||||
echo " - Linux builds success: $linux_builds_success"
|
|
||||||
|
|
||||||
# Build multi-arch Docker images
|
# Build multi-arch Docker images
|
||||||
# Strategy: Build images using pre-built binaries from dl.rustfs.com
|
# Strategy: Build images using pre-built binaries from dl.rustfs.com
|
||||||
# Supports both release and dev channel binaries based on build context
|
# Supports both release and dev channel binaries based on build context
|
||||||
# Only runs when Linux builds (x86_64 + aarch64) are successful
|
# Only runs when should_build is true (which includes workflow success check)
|
||||||
build-docker:
|
build-docker:
|
||||||
name: Build Docker Images
|
name: Build Docker Images
|
||||||
needs: build-check
|
needs: build-check
|
||||||
if: needs.build-check.outputs.should_build == 'true' && needs.build-check.outputs.linux_builds_success == 'true'
|
if: needs.build-check.outputs.should_build == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 60
|
timeout-minutes: 60
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
Reference in New Issue
Block a user