Skip to content

Commit 861ec35

Browse files
committed
chore: setup project
Signed-off-by: Brad McCoy <[email protected]>
1 parent cf118dc commit 861ec35

File tree

157 files changed

+9861
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+9861
-1
lines changed

.cosign/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# cdevents-controller signed releases
2+
3+
cdevents-controller deployment manifests are published to GitHub Container Registry as OCI artifacts
4+
and are signed using [cosign](https://github.com/sigstore/cosign).
5+
6+
## Verify the artifacts with cosign
7+
8+
Install the [cosign](https://github.com/sigstore/cosign) CLI:
9+
10+
```sh
11+
brew install sigstore/tap/cosign
12+
```
13+
14+
Verify a cdevents-controller release with cosign CLI:
15+
16+
```sh
17+
cosign verify -key https://raw.githubusercontent.com/bradmccoydev/cdevents-controller/master/cosign/cosign.pub \
18+
ghcr.io/bradmccoydev/cdevents-controller-deploy:latest
19+
```
20+
21+
## Download the artifacts with crane
22+
23+
Install the [crane](https://github.com/google/go-containerregistry/tree/main/cmd/crane) CLI:
24+
25+
```sh
26+
brew install crane
27+
```
28+
29+
Download the cdevents-controller deployment manifests with crane CLI:
30+
31+
```console
32+
$ crane export ghcr.io/bradmccoydev/cdevents-controller-deploy:latest -| tar -xf -
33+
34+
$ ls -1
35+
deployment.yaml
36+
hpa.yaml
37+
kustomization.yaml
38+
service.yaml
39+
```

.cosign/cosign.pub

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-----BEGIN PUBLIC KEY-----
2+
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEkl1Hmu0QNa3KhEXEvviUa5xyd84F
3+
7yBuaVIVaR7zL/h1t9JO8oV3/Y9NXhpFeFx1a9kkBUzPAoOqjQWwaCQVSQ==
4+
-----END PUBLIC KEY-----

.github/CODEOWNERS

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# CODEOWNERS file indicates code owners for certain files
2+
#
3+
# Code owners will automatically be added as a reviewer for PRs that touch
4+
# the owned files.
5+
#
6+
7+
# Default owners for everything in the repo
8+
#
9+
# Unless a later match takes precedence, these owners will be requested for
10+
# review when someone opens a pull request.
11+
12+
@bradmccoydev
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Setup kubeconform
2+
description: A GitHub Action for running kubeconform commands
3+
author: Stefan Prodan
4+
branding:
5+
color: blue
6+
icon: command
7+
inputs:
8+
version:
9+
description: "kubeconform version e.g. 0.5.0 (defaults to latest stable release)"
10+
required: false
11+
arch:
12+
description: "arch can be amd64 or arm64"
13+
required: true
14+
default: "amd64"
15+
runs:
16+
using: composite
17+
steps:
18+
- name: "Download binary to the GH runner cache"
19+
shell: bash
20+
run: |
21+
ARCH=${{ inputs.arch }}
22+
VERSION=${{ inputs.version }}
23+
24+
if [ -z $VERSION ]; then
25+
VERSION=$(curl https://api.github.com/repos/yannh/kubeconform/releases/latest -sL | grep tag_name | sed -E 's/.*"([^"]+)".*/\1/' | cut -c 2-)
26+
fi
27+
28+
BIN_URL="https://github.com/yannh/kubeconform/releases/download/v${VERSION}/kubeconform-linux-${ARCH}.tar.gz"
29+
BIN_DIR=$RUNNER_TOOL_CACHE/kubeconform/$VERSION/$ARCH
30+
31+
if [[ ! -x "$BIN_DIR/kind" ]]; then
32+
mkdir -p $BIN_DIR
33+
cd $BIN_DIR
34+
curl -sL $BIN_URL | tar xz
35+
chmod +x kubeconform
36+
fi
37+
38+
echo "$BIN_DIR" >> "$GITHUB_PATH"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM bradmccoydev/alpine-base:latest
2+
3+
COPY entrypoint.sh /entrypoint.sh
4+
RUN chmod +x /entrypoint.sh
5+
6+
ENTRYPOINT ["/entrypoint.sh"]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: 'github-release-notes'
2+
description: 'A GitHub Action to run github-release-notes commands'
3+
author: 'Stefan Prodan'
4+
branding:
5+
icon: 'command'
6+
color: 'blue'
7+
runs:
8+
using: 'docker'
9+
image: 'Dockerfile'
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit
4+
set -o pipefail
5+
6+
VERSION=0.2.0
7+
BIN_DIR="$GITHUB_WORKSPACE/bin"
8+
9+
main() {
10+
mkdir -p ${BIN_DIR}
11+
tmpDir=$(mktemp -d)
12+
13+
pushd $tmpDir >& /dev/null
14+
15+
curl -sSL https://github.com/buchanae/github-release-notes/releases/download/${VERSION}/github-release-notes-linux-amd64-${VERSION}.tar.gz | tar xz
16+
cp github-release-notes ${BIN_DIR}/github-release-notes
17+
18+
popd >& /dev/null
19+
rm -rf $tmpDir
20+
}
21+
22+
main
23+
24+
echo "$BIN_DIR" >> $GITHUB_PATH
25+
echo "$RUNNER_WORKSPACE/$(basename $GITHUB_REPOSITORY)/bin" >> $GITHUB_PATH
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
name: Build container
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
- '[0-9]+.[1-9][0-9]*.x'
8+
pull_request:
9+
branches:
10+
- 'main'
11+
- '[0-9]+.[1-9][0-9]*.x'
12+
paths-ignore:
13+
- "**.md"
14+
15+
env:
16+
GO_VERSION: "~1.20"
17+
IMAGE_NAME: "cdevents-controller"
18+
defaults:
19+
run:
20+
shell: bash
21+
22+
jobs:
23+
prepare_ci_run:
24+
name: Prepare CI Run
25+
runs-on: ubuntu-22.04
26+
outputs:
27+
GIT_SHA: ${{ steps.extract_branch.outputs.GIT_SHA }}
28+
BRANCH: ${{ steps.extract_branch.outputs.BRANCH }}
29+
BRANCH_SLUG: ${{ steps.extract_branch.outputs.BRANCH_SLUG }}
30+
DATETIME: ${{ steps.get_datetime.outputs.DATETIME }}
31+
BUILD_TIME: ${{ steps.get_datetime.outputs.BUILD_TIME }}
32+
NON_FORKED_AND_NON_ROBOT_RUN: ${{ steps.get_run_type.outputs.NON_FORKED_AND_NON_ROBOT_RUN }}
33+
34+
steps:
35+
- name: Check out code
36+
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
37+
38+
- name: Extract branch name
39+
id: extract_branch
40+
uses: keptn/gh-action-extract-branch-name@main
41+
42+
- name: Get current date and time
43+
id: get_datetime
44+
run: |
45+
DATETIME=$(date +'%Y%m%d%H%M')
46+
BUILD_TIME=$(date -u "+%F_%T")
47+
echo "DATETIME=$DATETIME" >> "$GITHUB_OUTPUT"
48+
echo "BUILD_TIME=$BUILD_TIME" >> "$GITHUB_OUTPUT"
49+
50+
- name: Get workflow run type
51+
id: get_run_type
52+
run: |
53+
NON_FORKED_AND_NON_ROBOT_RUN=${{ ( github.actor != 'renovate[bot]' && github.actor != 'dependabot[bot]' ) && ( github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository ) }}
54+
echo "github.actor != 'renovate[bot]' = ${{ github.actor != 'renovate[bot]' }}"
55+
echo "github.actor != 'dependabot[bot]' = ${{ github.actor != 'dependabot[bot]' }}"
56+
echo "github.event_name == 'push' = ${{ github.event_name == 'push' }}"
57+
echo "github.event.pull_request.head.repo.full_name == github.repository = ${{ github.event.pull_request.head.repo.full_name == github.repository }}"
58+
echo "NON_FORKED_AND_NON_ROBOT_RUN = $NON_FORKED_AND_NON_ROBOT_RUN"
59+
echo "NON_FORKED_AND_NON_ROBOT_RUN=$NON_FORKED_AND_NON_ROBOT_RUN" >> "$GITHUB_OUTPUT"
60+
61+
build_image:
62+
name: Build Container Image
63+
needs: prepare_ci_run
64+
runs-on: ubuntu-22.04
65+
env:
66+
BRANCH: ${{ needs.prepare_ci_run.outputs.BRANCH }}
67+
DATETIME: ${{ needs.prepare_ci_run.outputs.DATETIME }}
68+
BUILD_TIME: ${{ needs.prepare_ci_run.outputs.BUILD_TIME }}
69+
GIT_SHA: ${{ needs.prepare_ci_run.outputs.GIT_SHA }}
70+
RELEASE_REGISTRY: "localhost:5000/k8sgpt"
71+
steps:
72+
- name: Check out code
73+
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
74+
75+
- name: Set up Docker Buildx
76+
id: buildx
77+
uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c # v2
78+
79+
- name: Build Docker Image
80+
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4
81+
with:
82+
context: .
83+
platforms: linux/amd64
84+
file: ./container/Dockerfile
85+
target: production
86+
tags: |
87+
${{ env.RELEASE_REGISTRY }}/${{ env.IMAGE_NAME }}:dev-${{ env.DATETIME }}
88+
build-args: |
89+
GIT_HASH=${{ env.GIT_SHA }}
90+
RELEASE_VERSION=dev-${{ env.DATETIME }}
91+
BUILD_TIME=${{ env.BUILD_TIME }}
92+
builder: ${{ steps.buildx.outputs.name }}
93+
push: false
94+
cache-from: type=gha,scope=${{ github.ref_name }}-${{ env.IMAGE_NAME }}
95+
cache-to: type=gha,scope=${{ github.ref_name }}-${{ env.IMAGE_NAME }}
96+
outputs: type=docker,dest=/tmp/${{ env.IMAGE_NAME }}-image.tar
97+
98+
- name: Upload image as artifact
99+
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3
100+
with:
101+
name: ${{ env.IMAGE_NAME }}-image.tar
102+
path: /tmp/${{ env.IMAGE_NAME }}-image.tar
103+
104+
upload_images:
105+
name: Upload images to ghcr registry
106+
needs: [ prepare_ci_run, build_image ]
107+
if: github.event_name == 'push' && needs.prepare_ci_run.outputs.NON_FORKED_AND_NON_ROBOT_RUN == 'true' # only run on push to main/maintenance branches
108+
runs-on: ubuntu-22.04
109+
env:
110+
DATETIME: ${{ needs.prepare_ci_run.outputs.DATETIME }}
111+
BUILD_TIME: ${{ needs.prepare_ci_run.outputs.BUILD_TIME }}
112+
GIT_SHA: ${{ needs.prepare_ci_run.outputs.GIT_SHA }}
113+
permissions:
114+
packages: write # Needed for pushing images to the registry
115+
contents: read # Needed for checking out the repository
116+
steps:
117+
- name: Check out code
118+
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
119+
120+
- name: Login to GitHub Container Registry
121+
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2
122+
with:
123+
registry: "ghcr.io"
124+
username: ${{ github.actor }}
125+
password: ${{ secrets.GITHUB_TOKEN }}
126+
127+
- name: Set up Docker Buildx
128+
id: buildx
129+
uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c # v2
130+
131+
- name: Build Docker Image
132+
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4
133+
with:
134+
context: .
135+
file: ./container/Dockerfile
136+
platforms: linux/amd64,linux/arm64
137+
target: production
138+
tags: |
139+
ghcr.io/k8sgpt-ai/${{ env.IMAGE_NAME }}:dev-${{ env.DATETIME }}
140+
build-args: |
141+
GIT_HASH=${{ env.GIT_SHA }}
142+
RELEASE_VERSION=dev-${{ env.DATETIME }}
143+
BUILD_TIME=${{ env.BUILD_TIME }}
144+
builder: ${{ steps.buildx.outputs.name }}
145+
push: true
146+
cache-from: type=gha,scope=${{ github.ref_name }}-${{ env.IMAGE_NAME }}
147+
cache-to: type=gha,scope=${{ github.ref_name }}-${{ env.IMAGE_NAME }}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Run golangci-lint
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
7+
jobs:
8+
golangci-lint:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check out code into the Go module directory
12+
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
13+
14+
- name: golangci-lint
15+
uses: reviewdog/action-golangci-lint@79d32f10b2ea0d4cebb755d849b048c4b40c3d50 # v2
16+
with:
17+
github_token: ${{ secrets.GITHUB_TOKEN }}
18+
reporter: github-pr-check

0 commit comments

Comments
 (0)