Enhance CI Pipeline #9
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Container Images | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'images/**' | |
| pull_request: | |
| branches: [main] | |
| paths: | |
| - 'images/**' | |
| jobs: | |
| detect-changes: | |
| name: Detect Changed Images | |
| runs-on: ubuntu-latest | |
| outputs: | |
| images: ${{ steps.detect.outputs.images }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Detect changed image directories | |
| id: detect | |
| run: | | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| CHANGED=$(git diff --name-only "origin/${{ github.base_ref }}" "${{ github.sha }}" -- images/ \ | |
| | grep '^images/' \ | |
| | cut -d/ -f2 \ | |
| | sort -u) | |
| else | |
| BEFORE="${{ github.event.before }}" | |
| AFTER="${{ github.sha }}" | |
| # First push to branch has all-zero before SHA | |
| if [ "$BEFORE" = "0000000000000000000000000000000000000000" ]; then | |
| CHANGED=$(ls images/) | |
| else | |
| CHANGED=$(git diff --name-only "$BEFORE" "$AFTER" -- images/ \ | |
| | grep '^images/' \ | |
| | cut -d/ -f2 \ | |
| | sort -u) | |
| fi | |
| fi | |
| # Keep only entries that are actual image directories | |
| VALID="" | |
| for dir in $CHANGED; do | |
| [ -d "images/$dir" ] && VALID="$VALID $dir" | |
| done | |
| IMAGES=$(echo "$VALID" | tr ' ' '\n' | grep -v '^$' | jq -R -s -c 'split("\n") | map(select(length > 0))') | |
| echo "images=$IMAGES" >> "$GITHUB_OUTPUT" | |
| echo "Detected images: $IMAGES" | |
| build: | |
| name: Build ${{ matrix.image }} | |
| needs: detect-changes | |
| if: needs.detect-changes.outputs.images != '[]' && needs.detect-changes.outputs.images != '' | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| image: ${{ fromJson(needs.detect-changes.outputs.images) }} | |
| fail-fast: false | |
| env: | |
| SML_FIRECREST_CLIENT_ID: ${{ secrets.SML_FIRECREST_CLIENT_ID }} | |
| SML_FIRECREST_CLIENT_SECRET: ${{ secrets.SML_FIRECREST_CLIENT_SECRET }} | |
| SML_FIRECREST_TOKEN_URI: ${{ secrets.SML_FIRECREST_TOKEN_URI }} | |
| SML_FIRECREST_URL: ${{ secrets.SML_FIRECREST_URL }} | |
| SML_FIRECREST_SYSTEM: ${{ secrets.SML_FIRECREST_SYSTEM }} | |
| SML_PARTITION: ${{ secrets.SML_PARTITION }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: ./.github/actions/setup | |
| with: | |
| python-version: "3.12" | |
| - name: Build image and save sqsh | |
| run: python .github/scripts/build_image.py "${{ matrix.image }}" | |
| timeout-minutes: 300 | |
| env: | |
| PR_NUMBER: ${{ github.event.pull_request.number }} |