|
| 1 | +name: Build and publish container |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + tags: |
| 8 | + - "v*" |
| 9 | + pull_request: |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: container-${{ github.workflow }}-${{ github.ref }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + packages: write |
| 19 | + |
| 20 | +jobs: |
| 21 | + build: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Check out repository |
| 26 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 27 | + |
| 28 | + - name: Set lowercase image name |
| 29 | + id: image |
| 30 | + shell: bash |
| 31 | + run: echo "name=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT" |
| 32 | + |
| 33 | + - name: Set up QEMU |
| 34 | + uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0 |
| 35 | + |
| 36 | + - name: Set up Docker Buildx |
| 37 | + uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0 |
| 38 | + |
| 39 | + - name: Log in to GHCR |
| 40 | + if: github.event_name != 'pull_request' |
| 41 | + uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 |
| 42 | + with: |
| 43 | + registry: ghcr.io |
| 44 | + username: ${{ github.actor }} |
| 45 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 46 | + |
| 47 | + - name: Generate image metadata |
| 48 | + id: meta |
| 49 | + uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 |
| 50 | + with: |
| 51 | + images: ${{ steps.image.outputs.name }} |
| 52 | + tags: | |
| 53 | + type=raw,value=latest,enable={{is_default_branch}} |
| 54 | + type=ref,event=branch |
| 55 | + type=ref,event=tag |
| 56 | + type=sha,prefix=sha- |
| 57 | +
|
| 58 | + - name: Build and publish image |
| 59 | + uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 |
| 60 | + with: |
| 61 | + context: . |
| 62 | + platforms: linux/amd64,linux/arm64 |
| 63 | + push: ${{ github.event_name != 'pull_request' }} |
| 64 | + tags: ${{ steps.meta.outputs.tags }} |
| 65 | + labels: ${{ steps.meta.outputs.labels }} |
| 66 | + build-args: | |
| 67 | + CODEX_VERSION=latest |
| 68 | + VERSION=${{ github.sha }} |
| 69 | + cache-from: type=gha |
| 70 | + cache-to: type=gha,mode=max |
| 71 | + provenance: mode=max |
| 72 | + sbom: true |
0 commit comments