-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Aldo Lacuku <[email protected]>
- Loading branch information
Showing
3 changed files
with
199 additions
and
12 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 |
---|---|---|
@@ -0,0 +1,86 @@ | ||
name: docker-image | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
release: | ||
required: true | ||
type: string | ||
commit: | ||
required: true | ||
type: string | ||
build_date: | ||
required: true | ||
type: string | ||
sign: | ||
required: false | ||
default: false | ||
type: boolean | ||
outputs: | ||
digest: | ||
description: The digest of the pushed image. | ||
value: ${{ jobs.docker-image.outputs.digest }} | ||
|
||
jobs: | ||
docker-image: | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
image: ${{ steps.build-and-push.outputs.image }} | ||
digest: ${{ steps.build-and-push.outputs.digest }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 # v2.1.0 | ||
|
||
- name: Set up Docker Buildx | ||
id: Buildx | ||
uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c # v2.5.0 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USER }} | ||
password: ${{ secrets.DOCKERHUB_SECRET }} | ||
|
||
- name: Docker Meta | ||
id: meta_image | ||
uses: docker/metadata-action@507c2f2dc502c992ad446e3d7a5dfbe311567a96 # v4.3.0 | ||
with: | ||
# list of Docker images to use as base name for tags | ||
images: | | ||
docker.io/falcosecurity/k8s-metacollector | ||
tags: | | ||
type=ref,event=branch | ||
type=semver,pattern={{ version }} | ||
type=semver,pattern={{ major }} | ||
type=semver,pattern={{ major }}.{{ minor }} | ||
- name: Build and push | ||
id: build-and-push | ||
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4.0.0 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: ${{ steps.meta_image.outputs.tags }} | ||
file: ./build/Dockerfile | ||
build-args: | | ||
RELEASE=${{ inputs.release }} | ||
COMMIT=${{ inputs.commit }} | ||
BUILD_DATE=${{ inputs.build_date }} | ||
- name: Install Cosign | ||
if: ${{ inputs.sign }} | ||
uses: sigstore/cosign-installer@dd6b2e2b610a11fd73dd187a43d57cc1394e35f9 # v3.0.5 | ||
|
||
- name: Sign the images with GitHub OIDC Token | ||
if: ${{ inputs.sign }} | ||
env: | ||
DIGEST: ${{ steps.build-and-push.outputs.digest }} | ||
TAGS: ${{ steps.meta_image.outputs.tags }} | ||
COSIGN_YES: "true" | ||
run: echo "${TAGS}" | xargs -I {} cosign sign {}@${DIGEST} |
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 |
---|---|---|
@@ -0,0 +1,97 @@ | ||
name: Integration Pipeline | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-22.04 | ||
strategy: | ||
matrix: | ||
goos: | ||
- linux | ||
goarch: | ||
- arm64 | ||
- amd64 | ||
steps: | ||
- name: Checkout commit | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 | ||
with: | ||
go-version: '1.21.1' | ||
check-latest: true | ||
|
||
- name: Build k8s-metacollector | ||
run: > | ||
go build -ldflags="-s -w" -o k8s-metacollector-${{ matrix.goos }}-${{ matrix.goarch }} . | ||
env: | ||
CGO_ENABLED: 0 | ||
GOOS: ${{ matrix.goos }} | ||
GOARCH: ${{ matrix.goarch }} | ||
|
||
- name: Create Archives | ||
run: | | ||
cp k8s-metacollector-${{ matrix.goos }}-${{ matrix.goarch }} k8s-metacollector | ||
tar -czvf k8s-metacollector-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz k8s-metacollector LICENSE | ||
- name: Upload k8s-metacollector artifacts | ||
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 | ||
with: | ||
name: k8s-metacollector-${{ matrix.goos }}-${{ matrix.goarch }} | ||
path: ./k8s-metacollector-${{ matrix.goos }}-${{ matrix.goarch }} | ||
retention-days: 1 | ||
|
||
- name: Upload k8s-metacollector archives | ||
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 | ||
with: | ||
name: k8s-metacollector-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz | ||
path: ./k8s-metacollector-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz | ||
retention-days: 1 | ||
|
||
docker-configure: | ||
if: ${{ github.event_name == 'push' }} | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
release: ${{ steps.vars.outputs.release }} | ||
commit: ${{ steps.vars.outputs.commit }} | ||
build_date: ${{ steps.vars.outputs.build_date }} | ||
steps: | ||
- name: Set version fields | ||
id: vars | ||
run: | | ||
echo "release=${{ github.sha }}" >> $GITHUB_OUTPUT | ||
echo "commit=${{ github.sha }}" >> $GITHUB_OUTPUT | ||
echo "build_date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT | ||
docker-image: | ||
if: ${{ github.event_name == 'push' }} | ||
needs: docker-configure | ||
uses: ./.github/workflows/docker-image.yaml | ||
secrets: inherit | ||
with: | ||
release: ${{ needs.docker-configure.outputs.release }} | ||
commit: ${{ needs.docker-configure.outputs.commit }} | ||
build_date: ${{ needs.docker-configure.outputs.build_date }} | ||
|
||
test: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout commit | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 | ||
with: | ||
go-version: '1.21.1' | ||
check-latest: true | ||
|
||
- name: Run tests | ||
run: go test -cover ./... |
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