Merge pull request #691 from bbernhard/fix_ci

Fix ci
This commit is contained in:
Bernhard B.
2025-04-22 23:36:22 +02:00
committed by GitHub
7 changed files with 45 additions and 13 deletions

View File

@@ -27,6 +27,11 @@ jobs:
- uses: actions/checkout@master - uses: actions/checkout@master
with: with:
ref: ${{ github.ref }} ref: ${{ github.ref }}
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build - name: Build
env: env:
VERSION: ${{ github.run_number }} VERSION: ${{ github.run_number }}
@@ -34,7 +39,6 @@ jobs:
echo "Start CI build" echo "Start CI build"
docker run --privileged --rm tonistiigi/binfmt --install all docker run --privileged --rm tonistiigi/binfmt --install all
podman manifest create build podman manifest create build
podman build --format docker --platform linux/amd64,linux/arm64,linux/arm/v7 -t bbernhard/signal-cli-rest-api:${EPOCHSECONDS}-ci --manifest localhost/build . podman build --format docker --platform linux/amd64,linux/arm64,linux/arm/v7 --manifest localhost/build .
podman images podman manifest push localhost/build docker://docker.io/bbernhard/signal-cli-rest-api:${EPOCHSECONDS}-ci
podman push bbernhard/signal-cli-rest-api:${EPOCHSECONDS}-ci docker://docker.io/bbernhard/signal-cli-rest-api:${EPOCHSECONDS}-ci

View File

@@ -39,4 +39,6 @@ jobs:
echo "Start dev build" echo "Start dev build"
docker run --privileged --rm tonistiigi/binfmt --install all docker run --privileged --rm tonistiigi/binfmt --install all
podman manifest create build podman manifest create build
podman build --format docker --build-arg BUILD_VERSION_ARG=${VERSION} --manifest localhost/build --platform linux/amd64,linux/arm64,linux/arm/v7 -t bbernhard/signal-cli-rest-api:${VERSION}-dev -t bbernhard/signal-cli-rest-api:latest-dev . --push podman build --format docker --build-arg BUILD_VERSION_ARG=${VERSION} --manifest localhost/build --platform linux/amd64,linux/arm64,linux/arm/v7 .
podman manifest push localhost/build docker://docker.io/bbernhard/signal-cli-rest-api:${VERSION}-dev
podman manifest push localhost/build docker://docker.io/bbernhard/signal-cli-rest-api:latest-dev

View File

@@ -39,4 +39,6 @@ jobs:
echo "Start productive build" echo "Start productive build"
docker run --privileged --rm tonistiigi/binfmt --install all docker run --privileged --rm tonistiigi/binfmt --install all
podman manifest create build podman manifest create build
podman build --build-arg BUILD_VERSION_ARG=${VERSION} --manifest localhost/build --platform linux/amd64,linux/arm64,linux/arm/v7 -t bbernhard/signal-cli-rest-api:${VERSION} -t bbernhard/signal-cli-rest-api:latest . --push podman build --format docker --build-arg BUILD_VERSION_ARG=${VERSION} --manifest localhost/build --platform linux/amd64,linux/arm64,linux/arm/v7 .
podman manifest push localhost/build docker://docker.io/bbernhard/signal-cli-rest-api:${VERSION}
podman manifest push localhost/build docker://docker.io/bbernhard/signal-cli-rest-api:latest

View File

@@ -147,3 +147,5 @@ There are a bunch of environmental variables that can be set inside the docker c
* `PORT`: Defaults to port `8080` unless this env var is set to tell it otherwise. * `PORT`: Defaults to port `8080` unless this env var is set to tell it otherwise.
* `DEFAULT_SIGNAL_TEXT_MODE`: Allows to set the default text mode that should be used when sending a message (supported values: `normal`, `styled`). The setting is only used in case the `text_mode` is not explicitly set in the payload of the `send` method. * `DEFAULT_SIGNAL_TEXT_MODE`: Allows to set the default text mode that should be used when sending a message (supported values: `normal`, `styled`). The setting is only used in case the `text_mode` is not explicitly set in the payload of the `send` method.
* `LOG_LEVEL`: Allows to set the log level. Supported values: `debug`, `info`, `warn`, `error`. If nothing is specified, it defaults to `info`.

View File

@@ -1308,14 +1308,9 @@ func (a *Api) SetConfiguration(c *gin.Context) {
} }
if req.Logging.Level != "" { if req.Logging.Level != "" {
if req.Logging.Level == "debug" { err = utils.SetLogLevel(req.Logging.Level)
log.SetLevel(log.DebugLevel) if err != nil {
} else if req.Logging.Level == "info" { c.JSON(400, Error{Msg: err.Error()})
log.SetLevel(log.InfoLevel)
} else if req.Logging.Level == "warn" {
log.SetLevel(log.WarnLevel)
} else {
c.JSON(400, Error{Msg: "Couldn't set log level - invalid log level"})
return return
} }
} }

View File

@@ -69,6 +69,16 @@ func main() {
avatarTmpDir := flag.String("avatar-tmp-dir", "/tmp/", "Avatar tmp directory") avatarTmpDir := flag.String("avatar-tmp-dir", "/tmp/", "Avatar tmp directory")
flag.Parse() flag.Parse()
logLevel := utils.GetEnv("LOG_LEVEL", "")
if logLevel != "" {
err := utils.SetLogLevel(logLevel)
if err != nil {
log.Error("Couldn't set log level to '", logLevel, "'. Falling back to the info log level")
utils.SetLogLevel("info")
}
}
if utils.GetEnv("SWAGGER_USE_HTTPS_AS_PREFERRED_SCHEME", "false") == "false" { if utils.GetEnv("SWAGGER_USE_HTTPS_AS_PREFERRED_SCHEME", "false") == "false" {
docs.SwaggerInfo.Schemes = []string{"http", "https"} docs.SwaggerInfo.Schemes = []string{"http", "https"}
} else { } else {

View File

@@ -3,6 +3,8 @@ package utils
import ( import (
"os" "os"
"strconv" "strconv"
"errors"
log "github.com/sirupsen/logrus"
) )
func GetEnv(key string, defaultVal string) string { func GetEnv(key string, defaultVal string) string {
@@ -46,3 +48,18 @@ func IsPhoneNumber(s string) bool {
} }
return true return true
} }
func SetLogLevel(logLevel string) error {
if logLevel == "debug" {
log.SetLevel(log.DebugLevel)
} else if logLevel == "info" {
log.SetLevel(log.InfoLevel)
} else if logLevel == "error" {
log.SetLevel(log.ErrorLevel)
} else if logLevel == "warn" {
log.SetLevel(log.WarnLevel)
} else {
return errors.New("Couldn't set log level - invalid log level")
}
return nil
}