name: CD on: push: branches: - main paths: - "go.mod" - "go.sum" - "**/*.go" - "config.example.yaml" - "Dockerfile" - "Makefile" workflow_dispatch: env: DOCKER_REGISTRY: gitea.t000-n.de jobs: test: name: test runs-on: - ubuntu-latest - linux_amd64 steps: - name: Checkout uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 - name: Setup go uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6 with: go-version-file: go.mod check-latest: true - name: Create cache key uses: https://gitea.com/actions/go-hashfiles@264ae76b7e50173ce71ed7da4b48e5e517f3f9ec # v0.0.1 id: hash-go with: patterns: | go.mod go.sum - name: cache go id: cache-go uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5 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 strategy: matrix: arch: [amd64, arm64] needs: - test runs-on: - ubuntu-latest - linux_${{ matrix.arch }} steps: - name: Checkout uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 - name: Set up Docker Buildx uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3 - name: Login to Registry uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3 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@263435318d21b8e681c14492fe198d362a7d2c83 # v6 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@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 with: fetch-depth: 0 - uses: https://gitea.t000-n.de/t.behrendt/conventional-semantic-git-tag-increment@4c32e563bea346792d854585112bf6f06b312ce2 # 0.1.24 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@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 - 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@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3 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 \ ${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}-arm64 docker manifest push ${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:${{ needs.create_tag.outputs.tag }}