Add bake definition #1196
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: ci | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [main] | |
| tags: ["v*"] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| prepare: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| includes: ${{ steps.generate.outputs.matrix }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - | |
| name: Generate matrix | |
| id: generate | |
| uses: docker/bake-action/subaction/matrix@v6 | |
| with: | |
| target: validate | |
| validate: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - prepare | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: ${{ fromJson(needs.prepare.outputs.includes) }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Validate | |
| uses: docker/bake-action@v6 | |
| with: | |
| targets: ${{ matrix.target }} | |
| prepare-binaries: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| includes: ${{ steps.generate.outputs.matrix }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Generate matrix | |
| id: generate | |
| uses: docker/bake-action/subaction/matrix@v6 | |
| with: | |
| target: release | |
| fields: platforms | |
| binaries: | |
| needs: | |
| - prepare-binaries | |
| - validate | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: ${{ fromJson(needs.prepare-binaries.outputs.includes) }} | |
| env: | |
| DESTDIR: ./bin | |
| steps: | |
| - name: Prepare | |
| run: | | |
| platform=${{ matrix.platforms }} | |
| echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build | |
| uses: docker/bake-action@v6 | |
| with: | |
| source: . | |
| targets: release | |
| set: | | |
| *.platform=${{ matrix.platforms }} | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: cagent-${{ env.PLATFORM_PAIR }} | |
| path: ${{ env.DESTDIR }}/* | |
| if-no-files-found: error | |
| build-image: | |
| needs: | |
| - validate | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Hub login | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ vars.DOCKERPUBLICBOT_USERNAME }} | |
| password: ${{ secrets.DOCKERPUBLICBOT_WRITE_PAT }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: docker/cagent | |
| tags: | | |
| type=semver,pattern={{version}} | |
| type=edge | |
| type=ref,event=pr | |
| - name: Build and push image | |
| uses: docker/bake-action@v6 | |
| with: | |
| source: . | |
| files: | | |
| ./docker-bake.hcl | |
| ${{ steps.meta.outputs.bake-file }} | |
| targets: image-cross | |
| push: ${{ github.event_name != 'pull_request' }} | |
| sbom: true | |
| provenance: mode=max |