From 36aabf14dcff3463b59610a79b3da30926f4aa0e Mon Sep 17 00:00:00 2001 From: Richard87 Date: Mon, 14 Oct 2024 17:29:14 +0200 Subject: [PATCH] fix: manage nightly/release tags differently --- .github/workflows/release-please.yaml | 25 ++++++++++++++++++++++++- main.go | 6 +++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-please.yaml b/.github/workflows/release-please.yaml index bc0f674..0488ade 100644 --- a/.github/workflows/release-please.yaml +++ b/.github/workflows/release-please.yaml @@ -48,11 +48,34 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - type=semver,pattern=${{ env.TAG }} type=raw,value=latest-{{date 'YYYYMMDDHHmmss'}}-{{sha}} - name: Build and push Docker image uses: docker/build-push-action@v6 + if: ${{needs.release-please.outputs.release_created == 'true'}} + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }} + platforms: | + linux/amd64 + linux/arm64 + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Extract metadata (tags, labels) for Docker + id: meta + if: ${{ needs.release-please.outputs.release_created != 'true' }} + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest-{{date 'YYYYMMDDHHmmss'}}-{{sha}} + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + if: ${{ needs.release-please.outputs.release_created != 'true' }} with: context: . file: ./Dockerfile diff --git a/main.go b/main.go index c5b53e7..d5cb2a2 100644 --- a/main.go +++ b/main.go @@ -23,18 +23,18 @@ func main() { defer cancel() config := MustParseConfig() - queries := mustParseQueryFile(config.QueriesFile) + queries := MustParseQueryFile(config.QueriesFile) promController := NewPrometheusController(config.Prometheus.String(), queries) router := NewRouter(promController) - log.Ctx(ctx).Info().Strs("queries", slices.Collect(maps.Keys(queries))).Msg("Found queries") + log.Ctx(ctx).Info().Strs("found queries", slices.Collect(maps.Keys(queries))).Send() log.Ctx(ctx).Info().Msgf("Starting server on http://localhost:%d/query/{query}", config.Port) err := Serve(ctx, config.Port, router) log.Err(err).Msg("Terminated") } -func mustParseQueryFile(queriesFile string) map[string]string { +func MustParseQueryFile(queriesFile string) map[string]string { queries := map[string]string{} content, err := os.ReadFile(queriesFile) if err != nil {