Add github workflow

This commit is contained in:
Morten Lied Johansen 2024-10-02 16:14:33 +02:00
parent 0a1d03cee9
commit 0374b7cc20
No known key found for this signature in database
GPG key ID: 8DC6DECB15005221
3 changed files with 101 additions and 0 deletions

17
.github/dependabot.yml vendored Normal file
View file

@ -0,0 +1,17 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 5
groups:
k8s:
patterns:
- k8s.io/api*
- k8s.io/client-go
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 5

View file

@ -0,0 +1,23 @@
name: Dependabot auto-merge
on: pull_request
permissions:
contents: write
pull-requests: write
jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2.2.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Enable auto-merge for Dependabot PRs
if: steps.metadata.outputs.update-type != 'version-update:semver-major'
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

61
.github/workflows/main.yml vendored Normal file
View file

@ -0,0 +1,61 @@
name: Build and deploy
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
on:
push:
paths-ignore:
- '*.md'
jobs:
build:
name: Build and push
runs-on: ubuntu-22.04
permissions:
contents: write
id-token: write
steps:
- name: "Set build date"
id: constants
run: |
echo "build_date=$(date -Is)" >> ${GITHUB_OUTPUT}
- uses: actions/checkout@v4 # ratchet:actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Packages Docker Registry
if: github.base_ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install cosign
uses: sigstore/cosign-installer@4959ce089c160fddf62f7b42464195ba1a56d382 # ratchet:sigstore/cosign-installer@main
with:
cosign-release: 'v2.2.3'
- name: Verify runner image
run: cosign verify --certificate-identity keyless@distroless.iam.gserviceaccount.com --certificate-oidc-issuer https://accounts.google.com gcr.io/distroless/static-debian11
- name: "Docker metadata"
id: "metadata"
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=raw,value={{date 'YYYY-MM-DD-HHmmss' tz='Europe/Oslo'}}-{{sha}}
type=raw,value=latest
- name: "Build and push"
id: "build_push"
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
build-args: |
GIT_COMMIT=${{ github.sha }}
GIT_BRANCH=${{ github.ref }}
BUILD_DATE=${{ steps.constants.outputs.build_date }}
file: ./Dockerfile
push: ${{ github.base_ref == 'refs/heads/main' }}
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}