mirror of
https://github.com/paralus/paralus.git
synced 2026-08-24 15:47:19 +00:00
167 lines
5.0 KiB
YAML
167 lines
5.0 KiB
YAML
name: Create, Scan and Publish Container Images
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
tags: [ 'v*.*.*' ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
env:
|
|
REGISTRY: docker.io
|
|
IMAGE_NAME: paralusio/paralus
|
|
|
|
jobs:
|
|
|
|
build-push:
|
|
strategy:
|
|
matrix:
|
|
go-version: [1.17.x]
|
|
os: [ubuntu-latest]
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version: ${{ matrix.go-version }}
|
|
|
|
# Sanity check before publishing
|
|
- name: Create k8s Kind Cluster
|
|
uses: helm/kind-action@v1.2.0
|
|
|
|
- name: Test all
|
|
run: go test -v ./...
|
|
|
|
- name: Log in to the Container registry
|
|
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
|
|
- name: Extract metadata (tags, labels) for Docker
|
|
id: meta
|
|
uses: docker/metadata-action@c4ee3adeed93b1fa6a762f209fb01608c1a22f1e
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=ref,event=tag
|
|
type=ref,event=pr
|
|
type=sha
|
|
|
|
- name: Build and export to Docker
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: .
|
|
load: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
- name: Run Trivy vulnerability scanner
|
|
uses: aquasecurity/trivy-action@0.10.0
|
|
with:
|
|
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.tags }}
|
|
format: 'table'
|
|
exit-code: '1'
|
|
ignore-unfixed: true
|
|
vuln-type: 'os,library'
|
|
severity: 'CRITICAL,HIGH'
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v4
|
|
if: github.event_name != 'pull_request'
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
- name: Extract metadata (tags, labels) for Docker (paralus-init)
|
|
id: meta-init
|
|
uses: docker/metadata-action@c4ee3adeed93b1fa6a762f209fb01608c1a22f1e
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-init
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=ref,event=tag
|
|
type=ref,event=pr
|
|
type=sha
|
|
|
|
- name: Build and export to Docker (paralus-init)
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: .
|
|
load: true
|
|
tags: ${{ steps.meta-init.outputs.tags }}
|
|
|
|
- name: Run Trivy vulnerability scanner (paralus-init)
|
|
uses: aquasecurity/trivy-action@0.10.0
|
|
with:
|
|
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-init:${{ steps.meta-init.outputs.tags }}
|
|
format: 'table'
|
|
exit-code: '1'
|
|
ignore-unfixed: true
|
|
vuln-type: 'os,library'
|
|
severity: 'CRITICAL,HIGH'
|
|
|
|
- name: Build and push Docker image (paralus-init)
|
|
uses: docker/build-push-action@v4
|
|
if: github.event_name != 'pull_request'
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile.initialize
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta-init.outputs.tags }}
|
|
labels: ${{ steps.meta-init.outputs.labels }}
|
|
|
|
- name: Extract metadata (tags, labels) for Docker (kratos-sync)
|
|
id: meta-sync
|
|
uses: docker/metadata-action@c4ee3adeed93b1fa6a762f209fb01608c1a22f1e
|
|
with:
|
|
images: ${{ env.REGISTRY }}/paralusio/kratos-synchronizer
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=ref,event=tag
|
|
type=ref,event=pr
|
|
type=sha
|
|
|
|
- name: Build and export to Docker (kratos-sync)
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: .
|
|
load: true
|
|
tags: ${{ steps.meta-sync.outputs.tags }}
|
|
|
|
- name: Run Trivy vulnerability scanner (kratos-sync)
|
|
uses: aquasecurity/trivy-action@0.10.0
|
|
with:
|
|
image-ref: ${{ env.REGISTRY }}/paralusio/kratos-synchronizer:${{ steps.meta-sync.outputs.tags }}
|
|
format: 'table'
|
|
exit-code: '1'
|
|
ignore-unfixed: true
|
|
vuln-type: 'os,library'
|
|
severity: 'CRITICAL,HIGH'
|
|
|
|
- name: Build and push Docker image (kratos-sync)
|
|
uses: docker/build-push-action@v4
|
|
if: github.event_name != 'pull_request'
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile.synchronizer
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta-sync.outputs.tags }}
|
|
labels: ${{ steps.meta-sync.outputs.labels }}
|