-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
used docker build push github workflow
- Loading branch information
Showing
1 changed file
with
54 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |