From 6ac394bc31f56208e573db40c4fc7db4a904db5b Mon Sep 17 00:00:00 2001 From: Victor Morales Date: Wed, 8 Jan 2025 11:17:33 -0800 Subject: [PATCH] Enable docker build GH action --- .github/workflows/build.yml | 58 +++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..837b968 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,58 @@ +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# Copyright (c) 2025 +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +name: Create and publish Docker image +# yamllint disable-line rule:truthy +on: + workflow_dispatch: + push: + branches: + - "master" + tags: + - "v*" + pull_request: + branches: + - "master" +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} +jobs: + push-registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + attestations: write + id-token: write + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 + - name: Log in to the Container registry + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # 3.3.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # 5.6.1 + with: + images: ghcr.io/${{ github.repository }} + - name: Build and push Docker image + id: push + uses: docker/build-push-action@b32b51a8eda65d6793cd0494a773d4f6bcef32dc # 6.11.0 + with: + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + - name: Generate artifact attestation + uses: actions/attest-build-provenance@7668571508540a607bdfd90a87a560489fe372eb # 2.1.0 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true