From 380d7eaa4e16bd9d33eb2ca8a37279ea8a9aa093 Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Mon, 1 Apr 2024 21:47:18 +0200 Subject: [PATCH] refactor: CI/CD pipelines (#5) Reviewed-on: https://gitea.t000-n.de/t.behrendt/realDynDNS/pulls/5 Co-authored-by: Timo Behrendt Co-committed-by: Timo Behrendt --- .gitea/workflows/cd.yaml | 51 +++++++++++++++++++++++++++++++++------- .gitea/workflows/ci.yaml | 5 +--- 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/.gitea/workflows/cd.yaml b/.gitea/workflows/cd.yaml index 5407dda..b1d4396 100644 --- a/.gitea/workflows/cd.yaml +++ b/.gitea/workflows/cd.yaml @@ -1,19 +1,52 @@ name: CD on: - workflow_run: - workflows: - - CI + push: branches: - main - types: - - completed env: DOCKER_REGISTRY: gitea.t000-n.de 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 steps: - name: Checkout @@ -28,7 +61,7 @@ jobs: - name: Login to Registry uses: docker/login-action@v2 with: - registry: ${{ env.DOCKER_REGISTRY }} + registry: ${{ input.DOCKER_REGISTRY }} username: ${{ secrets.REGISTRY_USER }} password: ${{ secrets.REGISTRY_PASSWORD }} @@ -48,5 +81,5 @@ jobs: linux/arm64 push: true tags: | - ${{ env.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 }}:${{ steps.meta.outputs.REPO_VERSION }} + ${{ input.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:latest diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 8d5c7d9..dac1a20 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -1,9 +1,6 @@ name: CI on: pull_request: - push: - branches: - - main env: GOPATH: /go_path @@ -11,7 +8,7 @@ env: RUNNER_TOOL_CACHE: /toolcache jobs: - testing: + test: name: test runs-on: ubuntu-latest steps: