Skip to content

Commit

Permalink
wip: github actions to test and build/push
Browse files Browse the repository at this point in the history
  • Loading branch information
DrPsychick committed Aug 15, 2024
1 parent 7a27dfe commit 1a053a4
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "CodeQL"

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]


jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
language: [ 'go' ]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
69 changes: 69 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Publish

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
GO_VERSION: ~1.22

jobs:
publish:
name: Build operator image
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.meta.outputs.version }}
permissions:
contents: 'write'
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
check-latest: true

- name: OCI Metadata for multi-arch image
id: meta
uses: docker/metadata-action@v5
with:
images: |
drpsychick/mailu-operator
tags: |
type=sha
type=ref,event=pr
type=semver,pattern={{version}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
if: github.event_name != 'pull_request'
run: make buildx-build IMG=drpsychick/mailu-operator:${{ steps.meta.outputs.version }}

- name: Build operator install manifest
if: github.event_name != 'pull_request'
env:
RELEASE_VERSION: ${{ steps.meta.outputs.version }}
run: |
make build-installer IMG=drpsychick/mailu-operator:${{ steps.meta.outputs.version }}
- name: Commit operator install manifest
if: github.event_name != 'pull_request'
uses: stefanzweifel/git-auto-commit-action@v5
with:
file_pattern: 'dist/*.yaml'
33 changes: 33 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Test

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
GO_VERSION: ~1.22

jobs:
test:
name: unit and integration tests
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
check-latest: true

- name: Unit tests
run: make test

- name: Create KinD
uses: helm/kind-action@v1

- name: E2E tests
run: make test-e2e

0 comments on commit 1a053a4

Please sign in to comment.