chore(deps): bump docker/github-builder/.github/workflows/build.yml (… #81
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 and Publish Docker Images | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: &build-paths | |
| - "services/**/Dockerfile" | |
| - ".github/workflows/build-images.yml" | |
| pull_request: | |
| branches: | |
| - main | |
| paths: *build-paths | |
| workflow_dispatch: | |
| inputs: | |
| service: | |
| description: "Service to build (optional, builds all if not specified)" | |
| required: false | |
| default: "" | |
| jobs: | |
| output-services: | |
| name: Output Services to Build | |
| runs-on: ubuntu-latest | |
| outputs: | |
| services: ${{ steps.find.outputs.services }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - name: Define services to build | |
| id: find | |
| run: | | |
| services=() | |
| if [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ -n "${{ github.event.inputs.service }}" ]; then | |
| service_name="${{ github.event.inputs.service }}" | |
| if [ -f "services/${service_name}/Dockerfile" ]; then | |
| services+=("$service_name") | |
| echo "Building specified service: $service_name" | |
| else | |
| echo "Error: Service '$service_name' does not exist or does not have a Dockerfile" | |
| exit 1 | |
| fi | |
| else | |
| echo "No specific service input provided, searching for all services with Dockerfiles." | |
| for service_dir in services/*/; do | |
| if [ -f "${service_dir}Dockerfile" ]; then | |
| service_name=$(basename "$service_dir") | |
| services+=("$service_name") | |
| fi | |
| done | |
| fi | |
| # Convert to JSON array | |
| if [ ${#services[@]} -eq 0 ]; then | |
| json_array="[]" | |
| echo "No services found to build" | |
| else | |
| printf -v joined '%s,' "${services[@]}" | |
| json_array="[\"${joined%,}\"]" | |
| echo "Found services to build: ${json_array}" | |
| fi | |
| echo "services=${json_array}" >> "$GITHUB_OUTPUT" | |
| build-and-push: | |
| needs: output-services | |
| name: Build and Publish Image | |
| if: ${{ needs.output-services.outputs.services != '[]' }} | |
| strategy: | |
| matrix: | |
| service: ${{ fromJson(needs.output-services.outputs.services) }} | |
| include: | |
| - registry: ghcr.io | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| uses: docker/github-builder/.github/workflows/build.yml@3415a188caae9a0da7fba83bc06985776e0b1790 # v1.14.0 | |
| with: | |
| output: image | |
| push: ${{ github.event_name != 'pull_request' }} | |
| platforms: linux/amd64,linux/arm64,linux/arm/v7 | |
| context: ./services/${{ matrix.service }} | |
| meta-images: ${{ matrix.registry }}/${{ github.repository }}/${{ matrix.service }} | |
| meta-tags: | | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=sha,enable={{is_default_branch}} | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| cache: true | |
| cache-mode: max | |
| sbom: true | |
| set-meta-annotations: true | |
| set-meta-labels: true | |
| annotations: &labels | | |
| org.opencontainers.image.authors=https://github.com/${{ github.repository_owner }} | |
| org.opencontainers.image.documentation=https://github.com/${{ github.repository }}/tree/main/services/ | |
| labels: *labels | |
| secrets: | |
| registry-auths: | | |
| - registry: ${{ matrix.registry }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} |