Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 55 additions & 6 deletions .github/workflows/release_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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<<EOF'
echo '## Built container images'
echo
echo '| Image:Tag | Digest |'
echo '|---|---|'
# tags jsou newline-delimited
while IFS= read -r TAG; do
[[ -z "$TAG" ]] && continue
echo "| \`$TAG\` | \`$DIGEST\` |"
done <<< "${{ steps.meta.outputs.tags }}"
echo
echo '> 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
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions cmd/troll/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -75,7 +75,6 @@ func main() {
fmt.Printf(".")
}
fmt.Printf(" DONE\n\n")

}

// It is enought
Expand Down
13 changes: 10 additions & 3 deletions internal/server/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
}
Expand Down
Loading