Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(github action): Added workflow #1

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
name: CI Bmeme GCP Image Builder container image
on:
push:
branches:
- "*"
- "*/*"
- "**"
- "!main"

env:
registry: docker.io
repository: bmeme/gcp-image-builder

jobs:


build:
name: Build and test Bmeme GCP Image Builder container image using Docker
runs-on: ubuntu-latest
steps:
-
name: Check out the codebase.
uses: actions/checkout@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Lint Dockerfile
id: lint
uses: hadolint/[email protected]
with:
dockerfile: ./Dockerfile
config: .hadolint.yaml
-
name: Build image
id: build
run: |
{
TAG=$(cat Dockerfile | grep com.bmeme.project.version | awk -F\' '{print $2}');\
\
docker build \
-t ${{ env.registry }}/${{ env.repository }}:${TAG} \
-t ${{ env.registry }}/${{ env.repository }}:latest \
-f ./Dockerfile .
}
-
name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
id: trivy
with:
image-ref: ${{ env.registry }}/${{ env.repository }}:latest
format: 'sarif'
exit-code: '0'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL'
output: 'trivy-results-gke-helm-deployer.sarif'
-
name: Upload Trivy scan results to GitHub Security tab
id: trivy-upload
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results-gke-helm-deployer.sarif'
-
name: Scan image
id: scan
uses: anchore/scan-action@v3
with:
image: ${{ env.registry }}/${{ env.repository }}:latest
severity-cutoff: critical
fail-build: false
-
name: Upload Anchore scan SARIF report
id: scan-upload
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ${{ steps.scan.outputs.sarif }}
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: Release Bmeme GCP Image Builder container image
on:
push:
branches:
- "main"

env:
registry: docker.io
repository: bmeme/gcp-image-builder

jobs:

build:
name: Build and test Bmeme GCP Image Builder container image using Docker
runs-on: ubuntu-latest
steps:
-
name: Check out the codebase.
uses: actions/checkout@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build image
id: build
run: |
{
TAG=$(cat Dockerfile | grep com.bmeme.project.version | awk -F\' '{print $2}');\
\
docker build \
-t ${{ env.registry }}/${{ env.repository }}:${TAG} \
-t ${{ env.registry }}/${{ env.repository }}:latest \
-f ./Dockerfile .
}
-
name: Push images to Docker Hub
id: push
run: |
{
TAG=$(cat Dockerfile | grep com.bmeme.project.version | awk -F\' '{print $2}');\
docker push ${{ env.registry }}/${{ env.repository }}:${TAG}; \
docker push ${{ env.registry }}/${{ env.repository }}:latest; \
}
1 change: 1 addition & 0 deletions .hadolint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ ignored:

trustedRegistries:
- docker.io
- gcr.io
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM google/cloud-sdk:455.0.0-alpine as googlecloud-cli
FROM gcr.io/kaniko-project/executor AS kaniko
FROM gcr.io/kaniko-project/executor:v1.19.2 AS kaniko

FROM docker:24.0.7
LABEL com.bmeme.project.family='GKE-Docker Builder Image' \
Expand Down