diff --git a/.github/workflows/release_docker.yml b/.github/workflows/release_docker.yml index a281756..28f6739 100644 --- a/.github/workflows/release_docker.yml +++ b/.github/workflows/release_docker.yml @@ -25,10 +25,10 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Log in to the Container registry - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} @@ -57,16 +57,65 @@ jobs: - name: Build and push uses: docker/build-push-action@v6 with: - platforms: linux/amd64, linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64, linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} - name: COPY CONTAINER IMAGE NAME run: | echo "## :whale: There are available new images:" >> $GITHUB_STEP_SUMMARY + - name: Render build summary (markdown) + id: sum_md + shell: bash + run: | + DIGEST="${{ steps.build.outputs.digest }}" # manifest list digest + { + echo 'markdown< Note: all tags point to the same manifest digest above.' + echo 'EOF' + } >> "$GITHUB_OUTPUT" + + - name: Append to Job Summary + run: | + echo "${{ steps.sum_md.outputs.markdown }}" >> "$GITHUB_STEP_SUMMARY" + + - name: Add run annotation + run: | + MSG="$(echo "${{ steps.meta.outputs.tags }}" | tr '\n' ' ')" + echo "::notice title=Built images::${MSG} (digest ${{ steps.build.outputs.digest }})" + + # 6) PR komentář + - name: Comment on PR with images + if: ${{ github.event_name == 'pull_request' }} + uses: actions/github-script@v7 + with: + script: | + const body = process.env.MARKDOWN; + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body + }) + env: + MARKDOWN: ${{ steps.sum_md.outputs.markdown }} + + + + # - name: Build and release image # shell: bash diff --git a/README.md b/README.md index 1cc0745..315bc23 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ endpoints: | Name | Url | Notes | |---|---|---| - | FS: | ./v2_api.yaml | v2 config file have to be available. | + | FS: | ./config.yaml | Not required. | ### 📈 Monitoring @@ -195,10 +195,10 @@ Change log level by env LOG_LEVEL **Format** ```log -2023/04/18 16:41:11 [application:nodeName] INFO: Running env devel -2023/04/18 16:41:12 [application:nodeName] DEBUG: Metrics DB migration... -2023/04/18 16:41:12 [application:nodeName] DEBUG: Auth DB migration... -2023/04/18 16:41:12 [application:nodeName] INFO: Waiting for request at address :8080 +2023/04/18 16:41:11 INFO: Running env devel +2023/04/18 16:41:12 DEBUG: Metrics DB migration... +2023/04/18 16:41:12 DEBUG: Auth DB migration... +2023/04/18 16:41:12 INFO: Waiting for request at address :8080 ``` ### Backup diff --git a/cmd/troll/main.go b/cmd/troll/main.go index 2d2d100..403e2a6 100644 --- a/cmd/troll/main.go +++ b/cmd/troll/main.go @@ -29,7 +29,7 @@ func main() { flag.StringVar(&config.NAME, "name", libs.GetEnv("NAME", "troll"), "Define custom application name. (NAME)") flag.IntVar(&config.REQUEST_DELAY, "req-delay", libs.GetEnvInt("REQUEST_DELAY", 0), "Minimal delay before response on request [miliseconds]. (REQUEST_DELAY)") flag.StringVar(&config.DOC_ROOT, "root", libs.GetEnv("DOC_ROOT", "./public"), "Define document root for serving files. (DOC_ROOT)") - flag.StringVar(&config.CONFIG_FILE, "config", libs.GetEnv("CONFIG_FILE", "./config.yaml"), "Configure api endpoint. (CONFIG_FILE)") + flag.StringVar(&config.CONFIG_FILE, "config", libs.GetEnv("CONFIG_FILE", ""), "Configure api endpoint. (CONFIG_FILE)") flag.StringVar(&config.DSN, "dsn", libs.GetEnv("DSN", ""), "Define database DSN") flag.StringVar(&config.ADDRESS, "addr", libs.GetEnv("ADDRESS", ":8080"), "Define address and port where the application listen. (ADDRESS)") flag.StringVar(&config.LOG_LEVEL, "log", libs.GetEnv("LOG_LEVEL", "info"), "Define LOG_LEVEL") @@ -75,7 +75,6 @@ func main() { fmt.Printf(".") } fmt.Printf(" DONE\n\n") - } // It is enought diff --git a/internal/server/router.go b/internal/server/router.go index 723d78e..9a6f7af 100644 --- a/internal/server/router.go +++ b/internal/server/router.go @@ -61,8 +61,8 @@ func InitRoutes() *gin.Engine { // define default for not found router.NoRoute(handlers.HandleNotFound) - // if CONFIG_FILE exists, load routes - if _, err := os.Stat(config.CONFIG_FILE); err == nil { + if _, err := os.Stat(config.CONFIG_FILE); err == nil && config.CONFIG_FILE != "" { + // if CONFIG_FILE exists and not empty, load routes cfg := config.LoadYaml(config.CONFIG_FILE) // Game route initialization @@ -95,14 +95,21 @@ func InitRoutes() *gin.Engine { } } + + } else if config.CONFIG_FILE != "" && os.IsNotExist(err) { + // if CONFIG_FILE is not empty and does not exists, than FAIL + log.Printf("FATAL: Given config file \"%s\" does not exists!!!", config.CONFIG_FILE) + os.Exit(66) // File not found + } else { - log.Printf("WARN: Unable to find config file \"%s\", but continue..", config.CONFIG_FILE) + log.Println("WARN: Config file is not defined, but continue with defaults..") log.Println("INFO: Initialize default routes 🏗️ ...") v1 := router.Group("v1") config.Metrics.Use(v1) apiV1.RoutesAdd(v1) } + if config.LOG_LEVEL == "DEBUG" { log.Println("DEBUG [router.InitRoutes]: All routes has been initialized") }