|
| 1 | +# SPDX-FileCopyrightText: Copyright (c) 2025 Cisco and/or its affiliates. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +--- |
| 5 | +name: Build and Push |
| 6 | + |
| 7 | +on: |
| 8 | + workflow_call: |
| 9 | + inputs: |
| 10 | + bake-target: |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + description: "Bake target" |
| 14 | + bake-file: |
| 15 | + required: false |
| 16 | + type: string |
| 17 | + description: "Bake file" |
| 18 | + default: "docker-bake.hcl" |
| 19 | + image-name: |
| 20 | + required: true |
| 21 | + type: string |
| 22 | + description: "Image repo to use." |
| 23 | + image-tag: |
| 24 | + required: true |
| 25 | + type: string |
| 26 | + description: "Image tag to use." |
| 27 | + secrets: |
| 28 | + github-token: |
| 29 | + description: "github token" |
| 30 | + required: false |
| 31 | + |
| 32 | +jobs: |
| 33 | + build-and-push: |
| 34 | + name: Build and Push |
| 35 | + runs-on: ubuntu-latest |
| 36 | + |
| 37 | + steps: |
| 38 | + - name: Checkout code |
| 39 | + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 |
| 40 | + with: |
| 41 | + fetch-depth: 0 |
| 42 | + |
| 43 | + - name: Login to GitHub Container Registry |
| 44 | + if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }} |
| 45 | + uses: docker/login-action@v3 |
| 46 | + with: |
| 47 | + registry: ghcr.io |
| 48 | + username: ${{github.actor}} |
| 49 | + password: ${{secrets.github-token}} |
| 50 | + |
| 51 | + - name: Setup QEMU |
| 52 | + uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 |
| 53 | + |
| 54 | + - name: Setup Docker Buildx |
| 55 | + uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1 |
| 56 | + |
| 57 | + - name: Docker metadata |
| 58 | + id: metadata |
| 59 | + uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 |
| 60 | + with: |
| 61 | + images: | |
| 62 | + ghcr.io/agntcy/acp/${{ inputs.image-name }} |
| 63 | + tags: | |
| 64 | + type=raw,value=${{ inputs.image-tag }} |
| 65 | + type=raw,value=latest,enable=${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }} |
| 66 | +
|
| 67 | + - name: Build and push |
| 68 | + uses: docker/bake-action@a4d7f0b5b91c14a296d792d4ec53a9db17f02e67 # v5.5.0 |
| 69 | + with: |
| 70 | + files: | |
| 71 | + ${{ inputs.bake-file }} |
| 72 | + ${{ steps.metadata.outputs.bake-file }} |
| 73 | + targets: ${{ inputs.bake-target }} |
| 74 | + push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }} |
| 75 | + provenance: false |
0 commit comments