Compare commits

..

1 Commits

Author SHA1 Message Date
t.behrendt bc8e7e10e1 feat: adjust sample to mvp (#1)
CD / Create tag (push) Successful in 12s
CD / Build and push (amd64) (push) Successful in 1m38s
CD / Create manifest (push) Successful in 7s
Reviewed-on: #1
Co-authored-by: Timo Behrendt <t.behrendt@t00n.de>
Co-committed-by: Timo Behrendt <t.behrendt@t00n.de>
2026-05-17 14:39:46 +02:00
7 changed files with 145 additions and 59 deletions
+7
View File
@@ -0,0 +1,7 @@
*
!pkg
!controller.go
!main.go
!go.mod
!go.sum
-1
View File
@@ -14,4 +14,3 @@ runs:
id: hash-go id: hash-go
run: | run: |
echo "hash=$(sha256sum go.mod go.sum | sha256sum | cut -d' ' -f1)" >> "$GITHUB_OUTPUT" echo "hash=$(sha256sum go.mod go.sum | sha256sum | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
echo "hash=$hash" >> "$GITHUB_OUTPUT"
+104
View File
@@ -0,0 +1,104 @@
name: CD
on:
push:
branches:
- main
paths:
- "go.mod"
- "go.sum"
- "**/*.go"
- "Dockerfile"
- "Makefile"
workflow_dispatch:
env:
DOCKER_REGISTRY: gitea.t000-n.de
jobs:
build_and_push:
name: Build and push
strategy:
matrix:
arch: [amd64]
runs-on:
- ubuntu-latest
- linux_${{ matrix.arch }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Login to Registry
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Get Metadata
id: meta
run: |
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}' | tr '[:upper:]' '[:lower:]') >> $GITHUB_OUTPUT
echo REPO_VERSION=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
with:
context: .
file: ./Dockerfile
platforms: linux/${{ matrix.arch }}
push: true
provenance: false
build-args: GOARCH=${{ matrix.arch }}
tags: |
${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}-${{ matrix.arch }}
create_tag:
name: Create tag
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag.outputs.new-tag }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- uses: https://gitea.t000-n.de/t.behrendt/conventional-semantic-git-tag-increment@ef0c23189db33220a73022d8c29a27709d0df440 # 0.1.32
id: tag
with:
token: ${{ secrets.GITEA_TOKEN }}
prerelease: ${{ github.event_name == 'workflow_dispatch' }}
- run: |
git tag ${{ steps.tag.outputs.new-tag }}
git push origin ${{ steps.tag.outputs.new-tag }}
- name: Set output
run: |
echo "tag=${{ steps.tag.outputs.new-tag }}" >> $GITHUB_OUTPUT
create_manifest:
name: Create manifest
needs:
- build_and_push
- create_tag
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Get Metadata
id: meta
run: |
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}' | tr '[:upper:]' '[:lower:]') >> $GITHUB_OUTPUT
echo REPO_VERSION=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT
- name: Login to Registry
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Create manifest
run: |
docker manifest create ${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:${{ needs.create_tag.outputs.tag }} \
${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}-amd64
docker manifest push ${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:${{ needs.create_tag.outputs.tag }}
+9 -41
View File
@@ -9,64 +9,33 @@ env:
jobs: jobs:
install-dependencies: install-dependencies:
name: install dependencies uses: ./.gitea/workflows/install-go-dependencies.yaml
runs-on:
- ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install dependencies
uses: .gitea/workflows/install-go-dependencies
build-check: build-check:
name: build check name: build check
runs-on:
- ubuntu-latest
needs: install-dependencies needs: install-dependencies
steps: uses: ./.gitea/workflows/run-go-script.yaml
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Run build script
uses: .gitea/workflows/run-go-script
with: with:
script: build script: build
check-format: check-format:
name: check format name: check format
runs-on: needs: install-dependencies
- ubuntu-latest uses: ./.gitea/workflows/run-go-script.yaml
needs: build-check
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Run check format script
uses: .gitea/workflows/run-go-script
with: with:
script: check-format script: check-format
check-lint: check-lint:
name: check lint name: check lint
runs-on: needs: install-dependencies
- ubuntu-latest uses: ./.gitea/workflows/run-go-script.yaml
needs: build-check
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Run check lint script
uses: .gitea/workflows/run-go-script
with: with:
script: check-lint script: lint
test: test:
name: test name: test
runs-on: needs: install-dependencies
- ubuntu-latest uses: ./.gitea/workflows/run-go-script.yaml
needs: build-check
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Run test script
uses: .gitea/workflows/run-go-script
with: with:
script: test script: test
@@ -75,7 +44,6 @@ jobs:
runs-on: runs-on:
- ubuntu-latest - ubuntu-latest
- linux_amd64 - linux_amd64
needs: build-check
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+10 -5
View File
@@ -5,17 +5,20 @@ on:
jobs: jobs:
install-dependencies: install-dependencies:
runs-on: ubuntu-latest runs-on:
- ubuntu-latest
- linux_amd64
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup go - name: Setup go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0.4.0 uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with: with:
go-version-file: go.mod go-version-file: go.mod
check-latest: true check-latest: true
- name: Create cache key - name: Create cache key
uses: .gitea/actions/go-cache-key@main id: go-cache-key
uses: ./.gitea/actions/go-cache-key
- name: cache go - name: cache go
id: cache-go id: cache-go
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
@@ -23,6 +26,8 @@ jobs:
path: | path: |
/go_path /go_path
/go_cache /go_cache
key: go_path-${{ steps.hash-go.outputs.hash }} key: go_path-${{ steps.go-cache-key.outputs.hash }}
restore-keys: |- restore-keys: |-
go_cache-${{ steps.hash-go.outputs.hash }} go_cache-${{ steps.go-cache-key.outputs.hash }}
- name: Download dependencies
run: go mod download
+7 -4
View File
@@ -10,7 +10,9 @@ on:
jobs: jobs:
run-script: run-script:
runs-on: ubuntu-latest runs-on:
- ubuntu-latest
- linux_amd64
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -20,7 +22,8 @@ jobs:
go-version-file: go.mod go-version-file: go.mod
check-latest: true check-latest: true
- name: Create cache key - name: Create cache key
uses: .gitea/actions/go-cache-key@main id: go-cache-key
uses: ./.gitea/actions/go-cache-key
- name: Install dependencies from Cache - name: Install dependencies from Cache
id: cache-go id: cache-go
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
@@ -28,8 +31,8 @@ jobs:
path: | path: |
/go_path /go_path
/go_cache /go_cache
key: go_path-${{ steps.hash-go.outputs.hash }} key: go_path-${{ steps.go-cache-key.outputs.hash }}
restore-keys: |- restore-keys: |-
go_cache-${{ steps.hash-go.outputs.hash }} go_cache-${{ steps.go-cache-key.outputs.hash }}
- name: Run script - name: Run script
run: make ${{ inputs.script }} run: make ${{ inputs.script }}
+1 -1
View File
@@ -1,4 +1,4 @@
FROM docker.io/library/golang:1.25-alpine@sha256:04d017a27c481185c169884328a5761d052910fdced8c3b8edd686474efdf59b AS build FROM docker.io/library/golang:1.26.3@sha256:313faae491b410a35402c05d35e7518ae99103d957308e940e1ae2cfa0aac29b AS build
ARG GOARCH=amd64 ARG GOARCH=amd64