Minor fixes to CI workflow #597
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 Docker | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [ amd-staging ] | |
| paths: | |
| - 'Dockerfiles/**' | |
| - '.github/workflows/build_docker.yml' | |
| pull_request: | |
| branches: [ amd-staging, amd-mainline, release/** ] | |
| paths: | |
| - 'Dockerfiles/**' | |
| - '.github/workflows/build_docker.yml' | |
| permissions: | |
| contents: read | |
| packages: write | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.number || github.sha }} | |
| cancel-in-progress: true | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_PREFIX: ${{ github.repository }} | |
| jobs: | |
| find-dockerfiles: | |
| name: Find Dockerfiles | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| shell: bash | |
| outputs: | |
| files: ${{ steps.find-files.outputs.files }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Find Dockerfiles | |
| id: find-files | |
| run: | | |
| echo "## Finding all Dockerfiles in the 'Dockerfiles/' directory" | |
| FILES=$(find Dockerfiles/ -type f -printf "%f\n" | grep .*Dockerfile) | |
| echo "Found Dockerfiles:" | |
| echo "${FILES}" | |
| # Convert the array to JSON array | |
| JSON_ARRAY=$(printf '%s\n' "${FILES[@]}" | jq -R . | jq -s . | jq -c .) | |
| echo "JSON_ARRAY is" | |
| echo "${JSON_ARRAY}" | |
| echo "files=${JSON_ARRAY}" >> $GITHUB_OUTPUT | |
| build: | |
| name: Build Docker Images | |
| runs-on: ubuntu-latest | |
| needs: find-dockerfiles | |
| defaults: | |
| run: | |
| shell: bash | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| file: ${{fromJson(needs.find-dockerfiles.outputs.files)}} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Generate image tag | |
| id: image-tag | |
| run: | | |
| # Extract image name from Dockerfile name (e.g., "ubuntu-22.04.Dockerfile" -> "ubuntu-22.04") | |
| IMAGE_NAME=$(echo "${{ matrix.file }}" | sed 's/\.Dockerfile$//' | tr '[:upper:]' '[:lower:]') | |
| echo "name=${IMAGE_NAME}" >> $GITHUB_OUTPUT | |
| echo "Image name: ${IMAGE_NAME}" | |
| - name: Log in to GHCR | |
| if: github.event_name == 'push' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}-${{ steps.image-tag.outputs.name }} | |
| tags: | | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Build and push Docker image for ${{ matrix.file }} | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: Dockerfiles/ | |
| file: Dockerfiles/${{ matrix.file }} | |
| push: ${{ github.event_name == 'push' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} |