Skip to content

TEST: build cache node distribution test 1 #663

TEST: build cache node distribution test 1

TEST: build cache node distribution test 1 #663

name: Container image build and publish
on:
pull_request:
push:
branches:
- 'master'
- 'foreman-*.*'
env:
REGISTRY: quay.io
IMAGE_NAME: "iop/compliance-backend"
jobs:
build:
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
with:
persist-credentials: false
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20
with:
cosign-release: 'v2.2.4'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@3864d6aed8ff134b2ed894ce00c87695c709c870
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.QUAY_IOP_BUILD_USERNAME }}
password: ${{ secrets.QUAY_IOP_BUILD_PASSWORD }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=sha
type=raw,value=latest,enable=${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@ff26911fd365b0233252dfbd8eede1c0e9ef9a51
with:
platforms: linux/amd64
context: .
file: ./Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,push=${{ github.event_name != 'pull_request' }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Sign the published Docker image
if: github.event_name != 'pull_request'
env:
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}