2020-12-27 07:43:30 +00:00
|
|
|
---
|
2020-12-21 11:10:02 +00:00
|
|
|
name: Publish
|
|
|
|
on:
|
2021-01-21 09:48:48 +00:00
|
|
|
workflow_dispatch:
|
2020-12-21 11:10:02 +00:00
|
|
|
push:
|
|
|
|
tags:
|
|
|
|
- "v*"
|
2020-12-27 07:43:30 +00:00
|
|
|
env:
|
|
|
|
ALIAS: aquasecurity
|
2021-01-21 10:22:28 +00:00
|
|
|
DOCKERHUB_ALIAS: aquasec
|
2020-12-27 07:43:30 +00:00
|
|
|
REP: kube-bench
|
2020-12-21 11:10:02 +00:00
|
|
|
jobs:
|
|
|
|
publish:
|
|
|
|
name: Publish
|
|
|
|
runs-on: ubuntu-18.04
|
|
|
|
steps:
|
|
|
|
- name: Check Out Repo
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v1
|
2020-12-27 07:43:30 +00:00
|
|
|
- name: Set up Docker Buildx
|
|
|
|
id: buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
2020-12-21 11:10:02 +00:00
|
|
|
- name: Cache Docker layers
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: /tmp/.buildx-cache
|
2020-12-27 07:43:30 +00:00
|
|
|
key: ${{ runner.os }}-buildxarch-${{ github.sha }}
|
2020-12-21 11:10:02 +00:00
|
|
|
restore-keys: |
|
2020-12-27 07:43:30 +00:00
|
|
|
${{ runner.os }}-buildxarch-
|
2020-12-21 11:10:02 +00:00
|
|
|
- name: Login to Docker Hub
|
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
2020-12-27 07:43:30 +00:00
|
|
|
username: ${{ secrets.DOCKERHUB_USER }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Login to ECR
|
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
|
|
|
registry: public.ecr.aws
|
|
|
|
username: ${{ secrets.ECR_ACCESS_KEY_ID }}
|
|
|
|
password: ${{ secrets.ECR_SECRET_ACCESS_KEY }}
|
|
|
|
- name: Get version
|
|
|
|
id: get_version
|
2021-08-04 08:38:18 +00:00
|
|
|
uses: crazy-max/ghaction-docker-meta@v3
|
2020-12-21 11:10:02 +00:00
|
|
|
with:
|
2020-12-27 07:43:30 +00:00
|
|
|
images: ${{ env.REP }}
|
2020-12-21 11:10:02 +00:00
|
|
|
tag-semver: |
|
|
|
|
{{version}}
|
2020-12-27 07:43:30 +00:00
|
|
|
|
|
|
|
- name: Build and push - Docker/ECR
|
2020-12-21 11:10:02 +00:00
|
|
|
id: docker_build
|
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
2020-12-27 07:43:30 +00:00
|
|
|
context: .
|
|
|
|
platforms: linux/amd64
|
2020-12-21 11:10:02 +00:00
|
|
|
builder: ${{ steps.buildx.outputs.name }}
|
|
|
|
push: true
|
|
|
|
tags: |
|
2021-01-21 10:27:46 +00:00
|
|
|
${{ env.DOCKERHUB_ALIAS }}/${{ env.REP }}:${{ steps.get_version.outputs.version }}
|
2020-12-27 07:43:30 +00:00
|
|
|
public.ecr.aws/${{ env.ALIAS }}/${{ env.REP }}:${{ steps.get_version.outputs.version }}
|
2021-01-21 10:27:46 +00:00
|
|
|
${{ env.DOCKERHUB_ALIAS }}/${{ env.REP }}:latest
|
2020-12-27 07:43:30 +00:00
|
|
|
public.ecr.aws/${{ env.ALIAS }}/${{ env.REP }}:latest
|
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache/release
|
|
|
|
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache/release
|
2020-12-21 11:10:02 +00:00
|
|
|
- name: Image digest
|
|
|
|
run: echo ${{ steps.docker_build.outputs.digest }}
|