Skip to content

Commit

Permalink
chore: add workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
soerenschneider committed Sep 2, 2024
1 parent 3554c3b commit bde0189
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/container-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

---
name: Create and publish a container

on:
push:
branches:
- main
workflow_dispatch: {}

env:
GH_REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

permissions:
packages: write

jobs:
build-and-push-image:
runs-on: ubuntu-latest

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

- name: Log in to the gcr registry
uses: docker/[email protected]
with:
registry: ${{ env.GH_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for container
id: gcr
uses: docker/[email protected]
with:
images: ${{ env.GH_REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value={{ branch}}-{{date 'YYYYMMDDHHmmss'}}
type=ref,event=branch
type=ref,event=pr
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push container image
uses: docker/[email protected]
with:
context: .
push: true
tags: ${{ steps.gcr.outputs.tags }}
labels: ${{ steps.gcr.outputs.labels }}
27 changes: 27 additions & 0 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: golangci-lint

on:
push:
pull_request:

permissions:
contents: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]

- uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: false

- name: golangci-lint
uses: golangci/[email protected]
with:
version: "latest"
args: "--timeout=30m"
58 changes: 58 additions & 0 deletions .github/workflows/release-container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
on:
push:
branches:
- main

permissions:
contents: write
pull-requests: write
packages: write

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

name: release

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: GoogleCloudPlatform/[email protected]
name: release
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: simple
package-name: ${{ github.repository }}

- name: Checkout
uses: actions/[email protected]
if: ${{ steps.release.outputs.release_created }}

- name: Log in to the container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
if: ${{ steps.release.outputs.release_created }}

- name: Extract metadata for container
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}},value=v${{steps.release.outputs.major }}.${{steps.release.outputs.minor }}.${{steps.release.outputs.patch }}
if: ${{ steps.release.outputs.release_created }}

- name: Build and push container image
uses: docker/[email protected]
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
if: ${{ steps.release.outputs.release_created }}
22 changes: 22 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: test

on:
push:
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]

- uses: actions/setup-go@v5
with:
go-version: '1.23'

- name: build binary
run: make build

- name: run all tests
run: make tests

0 comments on commit bde0189

Please sign in to comment.