Skip to content

Commit

Permalink
used docker build push github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
saidsef committed Sep 2, 2021
1 parent 7c46114 commit 92610d5
Showing 1 changed file with 54 additions and 15 deletions.
69 changes: 54 additions & 15 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,77 @@
name: Docker Image CI
name: CI
on:
push:
branches:
- master
paths:
- "Dockerfile"
- ".github/workflows/docker.yml"
pull_request:
branches:
- master
paths:
- "Dockerfile"
- ".github/workflows/docker.yml"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Checkout source code
uses: actions/checkout@v2
- name: Set Tag Name
run: |
echo "TAG=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
- name: Build docker image
run: |
docker build -t docker.io/saidsef/aws-kinesis-local:${{ env.TAG }} .
- name: Run Trivy vulnerability scanner
echo "DATE=v$(echo `date +'%Y.%m'`)" >> $GITHUB_ENV
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image - (TAG)
uses: docker/build-push-action@v2
env:
DOCKER_BUILDKIT: 1
with:
context: .
push: true
tags: docker.io/saidsef/aws-kinesis-local:${{ env.TAG == 'master' && 'latest' || env.TAG }}
- name: Build and push Docker image - (MAIN)
uses: docker/build-push-action@v2
if: ${{ contains(github.ref, 'master') }}
env:
DOCKER_BUILDKIT: 1
with:
context: .
push: true
tags: docker.io/saidsef/aws-kinesis-local:${{ env.DATE }}
- name: Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: docker.io/saidsef/aws-kinesis-local:${{ env.TAG }}
format: 'template'
template: '@/contrib/sarif.tpl'
output: 'trivy-results.sarif'
- name: Upload Trivy scan results to GitHub Security tab
- name: Upload Trivy scan results to GitHub Security
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: 'trivy-results.sarif'
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build docker image
run: |
docker push docker.io/saidsef/aws-kinesis-local:${{ env.TAG }}

k8s-test:
runs-on: ubuntu-latest
needs: [build]
if: ${{ ! contains(github.ref, 'master') }}
steps:
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1.2.0
- name: Checkout
uses: actions/checkout@v2
- name: Run K8s test
run: |
kubectl cluster-info
export NS=`cat deployment/kustomization.yml | grep namespace | awk '{ print $2 }'`
if [ -z "$NS" ]; then
export NS='data'
fi
kubectl create namespace $NS
kubectl apply -n $NS -k deployment/
kubectl get all -n $NS

0 comments on commit 92610d5

Please sign in to comment.