refactor: CI/CD pipelines (#5)
Some checks failed
CD / test (push) Successful in 43s
CD / Build and push (push) Failing after 26s

Reviewed-on: #5
Co-authored-by: Timo Behrendt <t.behrendt@t00n.de>
Co-committed-by: Timo Behrendt <t.behrendt@t00n.de>
This commit was merged in pull request #5.
This commit is contained in:
2024-04-01 21:47:18 +02:00
committed by t.behrendt
parent 74c38313a2
commit 380d7eaa4e
2 changed files with 43 additions and 13 deletions

View File

@@ -1,19 +1,52 @@
name: CD name: CD
on: on:
workflow_run: push:
workflows:
- CI
branches: branches:
- main - main
types:
- completed
env: env:
DOCKER_REGISTRY: gitea.t000-n.de DOCKER_REGISTRY: gitea.t000-n.de
jobs: jobs:
build: test:
name: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true
- name: Create cache key
uses: https://gitea.com/actions/go-hashfiles@v0.0.1
id: hash-go
with:
patterns: |
go.mod
go.sum
- name: cache go
id: cache-go
uses: actions/cache@v4
with:
path: |
/go_path
/go_cache
key: go_path-${{ steps.hash-go.outputs.hash }}
restore-keys: |-
go_cache-${{ steps.hash-go.outputs.hash }}
- name: build
run: make build
- name: test
run: make test
build_and_push:
name: Build and push
requires:
- test
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
@@ -28,7 +61,7 @@ jobs:
- name: Login to Registry - name: Login to Registry
uses: docker/login-action@v2 uses: docker/login-action@v2
with: with:
registry: ${{ env.DOCKER_REGISTRY }} registry: ${{ input.DOCKER_REGISTRY }}
username: ${{ secrets.REGISTRY_USER }} username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }} password: ${{ secrets.REGISTRY_PASSWORD }}
@@ -48,5 +81,5 @@ jobs:
linux/arm64 linux/arm64
push: true push: true
tags: | tags: |
${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }} ${{ input.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}
${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:latest ${{ input.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:latest

View File

@@ -1,9 +1,6 @@
name: CI name: CI
on: on:
pull_request: pull_request:
push:
branches:
- main
env: env:
GOPATH: /go_path GOPATH: /go_path
@@ -11,7 +8,7 @@ env:
RUNNER_TOOL_CACHE: /toolcache RUNNER_TOOL_CACHE: /toolcache
jobs: jobs:
testing: test:
name: test name: test
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps: