Skip to content

Commit 4ce6152

Browse files
committed
Add CI to the github repo
This change brings in several CI related changes: 1. On branch push, lint helm, lint go, run unit tests, validate CNAB, publish the docker image, publish the helm chart. 2. On branch push, also run container scanning using trivy and upload trivy results to the repo. 3. On tag cut (vX.Y.Z), publish the image to docker.io, publish the chart to docker.io, and bundle CNAB and upload to the marketplace ACR.
1 parent b3a0167 commit 4ce6152

File tree

16 files changed

+718
-254
lines changed

16 files changed

+718
-254
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/workflows/build-and-sign-image.yml

Lines changed: 0 additions & 101 deletions
This file was deleted.
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: "dev-workflow"
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
7+
permissions:
8+
id-token: write
9+
contents: read
10+
actions: read
11+
security-events: write
12+
13+
14+
jobs:
15+
lint_test_build:
16+
runs-on: ubuntu-latest
17+
18+
env:
19+
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
20+
21+
steps:
22+
- name: Checkout Repo
23+
uses: actions/checkout@v5
24+
with:
25+
fetch-depth: 2
26+
27+
- name: Azure Login via OIDC
28+
uses: azure/login@v2
29+
with:
30+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
31+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
32+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
33+
34+
- name: Docker Login to Azure Container Registry
35+
run: |
36+
registry_name=${{ secrets.DOCKER_REGISTRY_PROD }}
37+
az acr login --name ${registry_name%%.*}
38+
39+
- name: "lint + unit-test + build"
40+
env:
41+
DOCKER_REGISTRY_PROD: ${{ secrets.DOCKER_REGISTRY_PROD }}
42+
run: |
43+
if [ "$GITHUB_REF_NAME" != "$DEFAULT_BRANCH" ]; then
44+
time make helm-lint
45+
# Only run Go linting if Go files have changed
46+
if git diff --name-only HEAD~1 HEAD | grep -E '\.(go|mod)$'; then
47+
echo "Go files detected in changes, running Go linters..."
48+
time make lint
49+
git diff --exit-code
50+
else
51+
echo "No Go files changed, skipping Go linting..."
52+
fi
53+
time make test
54+
fi
55+
time make publish
56+
time make publish-helm
57+
58+
validate_cnab:
59+
runs-on: ubuntu-latest
60+
61+
steps:
62+
- name: Checkout Repo
63+
uses: actions/checkout@v5
64+
with:
65+
fetch-depth: 2
66+
67+
- name: Azure Login via OIDC
68+
uses: azure/login@v2
69+
with:
70+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
71+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
72+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
73+
74+
- name: Docker Login to Azure Container Registry
75+
run: |
76+
registry_name=${{ secrets.DOCKER_REGISTRY_PROD }}
77+
az acr login --name ${registry_name%%.*}
78+
79+
- name: "validate-cnab"
80+
run: time make validate-cnab
81+
82+
security_scanning:
83+
needs: [lint_test_build, validate_cnab]
84+
runs-on: ubuntu-latest
85+
86+
env:
87+
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
88+
89+
steps:
90+
- name: Checkout Repo
91+
uses: actions/checkout@v5
92+
with:
93+
fetch-depth: 2
94+
95+
- name: Azure Login via OIDC
96+
uses: azure/login@v2
97+
with:
98+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
99+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
100+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
101+
102+
- name: Docker Login to Azure Container Registry
103+
run: |
104+
registry_name=${{ secrets.DOCKER_REGISTRY_PROD }}
105+
az acr login --name ${registry_name%%.*}
106+
107+
- name: "NLK image scanning"
108+
env:
109+
DOCKER_REGISTRY_PROD: ${{ secrets.DOCKER_REGISTRY_PROD }}
110+
run: time make scan-container-image
111+
112+
- name: Upload SARIF
113+
uses: github/codeql-action/upload-sarif@v4
114+
with:
115+
sarif_file: results/trivy/trivy-results.sarif
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: dockerhub-release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
id-token: write
10+
contents: read
11+
12+
jobs:
13+
dockerhub-release:
14+
runs-on: ubuntu-latest
15+
if: >
16+
startsWith(github.ref_name, 'v') &&
17+
github.ref_type == 'tag' &&
18+
contains(github.ref_name, '.')
19+
steps:
20+
- name: Checkout Repo
21+
uses: actions/checkout@v4
22+
23+
- name: Azure Login via OIDC
24+
uses: azure/login@v2
25+
with:
26+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
27+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
28+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
29+
30+
- name: Docker Login to the Source Azure Container Registry
31+
run: |
32+
registry_name=${{ secrets.DOCKER_REGISTRY_PROD }}
33+
az acr login --name ${registry_name%%.*}
34+
35+
- name: Release Docker Image to Dockerhub
36+
run: make release-docker-image
37+
env:
38+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
39+
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
40+
DOCKER_REGISTRY_PROD: ${{ secrets.DOCKER_REGISTRY_PROD }}
41+
42+
- name: Release Helm Chart to Dockerhub
43+
run: make release-helm-chart
44+
env:
45+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
46+
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
47+
DOCKER_REGISTRY_PROD: ${{ secrets.DOCKER_REGISTRY_PROD }}
48+
49+
cnab-release:
50+
needs: [dockerhub-release]
51+
runs-on: ubuntu-latest
52+
53+
if: >
54+
startsWith(github.ref_name, 'v') &&
55+
github.ref_type == 'tag' &&
56+
contains(github.ref_name, '.')
57+
58+
steps:
59+
- name: Checkout Repo
60+
uses: actions/checkout@v4
61+
62+
- name: Azure Login via OIDC
63+
uses: azure/login@v2
64+
with:
65+
client-id: ${{ secrets.AZURE_MARKETPLACE_CLIENT_ID }}
66+
tenant-id: ${{ secrets.AZURE_MARKETPLACE_TENANT_ID }}
67+
subscription-id: ${{ secrets.AZURE_MARKETPLACE_SUBSCRIPTION_ID }}
68+
69+
- name: Docker Login to the Marketplace Azure Container Registry
70+
run: |
71+
registry_name=${{ secrets.DOCKER_REGISTRY_MARKETPLACE }}
72+
az acr login --name ${registry_name%%.*}
73+
74+
- name: Release CNAB Bundle to Marketplace Registry
75+
run: make release-cnab
76+
env:
77+
DOCKER_REGISTRY_PROD: ${{ secrets.DOCKER_REGISTRY_PROD }}

0 commit comments

Comments
 (0)