Skip to content

Commit

Permalink
moved to min branch and docker tags to params
Browse files Browse the repository at this point in the history
  • Loading branch information
saidsef committed Oct 24, 2021
1 parent c9aa0bd commit 3eaaf36
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@ name: CI
on:
push:
branches:
- master
- main
paths:
- "Dockerfile"
- ".github/workflows/docker.yml"
pull_request:
branches:
- master
- main
paths:
- "Dockerfile"
- ".github/workflows/docker.yml"

env:
REGISTRY: docker.io
OWNER: ${{ github.repository_owner }}

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -22,10 +27,12 @@ jobs:
run: |
echo "TAG=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
echo "DATE=v$(echo `date +'%Y.%m'`)" >> $GITHUB_ENV
echo "REPO_NAME=$(echo ${PWD##*/})" >> $GITHUB_ENV
- name: Login to DockerHub
uses: docker/login-action@v1
if: success()
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up QEMU
Expand All @@ -49,10 +56,10 @@ jobs:
platforms: linux/amd64,linux/arm64
pull: true
push: true
tags: docker.io/saidsef/aws-kinesis-local:${{ env.TAG == 'master' && 'latest' || env.TAG }}
tags: ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.REPO_NAME }}:${{ env.TAG == 'main' && 'latest' || env.TAG }}
- name: Build and push Docker image - (MAIN)
uses: docker/build-push-action@v2
if: ${{ contains(github.ref, 'master') }}
if: ${{ contains(github.ref, 'main') }}
env:
DOCKER_BUILDKIT: 1
with:
Expand All @@ -61,12 +68,12 @@ jobs:
platforms: linux/amd64,linux/arm64
pull: true
push: true
tags: docker.io/saidsef/aws-kinesis-local:${{ env.DATE }}
tags: ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.REPO_NAME }}:${{ env.DATE }}
- name: Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
if: success()
with:
image-ref: docker.io/saidsef/aws-kinesis-local:${{ env.TAG == 'master' && 'latest' || env.TAG }}
image-ref: ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.REPO_NAME }}:${{ env.TAG == 'main' && 'latest' || env.TAG }}
format: 'template'
template: '@/contrib/sarif.tpl'
output: 'trivy-results.sarif'
Expand All @@ -79,7 +86,7 @@ jobs:
k8s-test:
runs-on: ubuntu-latest
needs: [build]
if: ${{ ! contains(github.ref, 'master') }}
if: ${{ ! contains(github.ref, 'main') }}
steps:
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1.2.0
Expand All @@ -94,4 +101,15 @@ jobs:
fi
kubectl create namespace $NS
kubectl apply -n $NS -k deployment/
kubectl get all -n $NS
kubectl get all -n $NS
auto-approve:
runs-on: ubuntu-latest
needs: [build, k8s-test]
if: ${{ github.event_name == 'pull_request' }}
steps:
- name: Check out repository code
uses: actions/checkout@v2
- uses: hmarr/auto-approve-action@v2
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

0 comments on commit 3eaaf36

Please sign in to comment.