mirror of
https://github.com/aljazceru/signal-cli-rest-api.git
synced 2025-12-19 15:44:28 +01:00
10
.github/workflows/ci.yml
vendored
10
.github/workflows/ci.yml
vendored
@@ -27,6 +27,11 @@ jobs:
|
||||
- uses: actions/checkout@master
|
||||
with:
|
||||
ref: ${{ github.ref }}
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Build
|
||||
env:
|
||||
VERSION: ${{ github.run_number }}
|
||||
@@ -34,7 +39,6 @@ jobs:
|
||||
echo "Start CI build"
|
||||
docker run --privileged --rm tonistiigi/binfmt --install all
|
||||
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 images
|
||||
podman push bbernhard/signal-cli-rest-api:${EPOCHSECONDS}-ci docker://docker.io/bbernhard/signal-cli-rest-api:${EPOCHSECONDS}-ci
|
||||
podman build --format docker --platform linux/amd64,linux/arm64,linux/arm/v7 --manifest localhost/build .
|
||||
podman manifest push localhost/build docker://docker.io/bbernhard/signal-cli-rest-api:${EPOCHSECONDS}-ci
|
||||
|
||||
|
||||
4
.github/workflows/release-dev-version.yml
vendored
4
.github/workflows/release-dev-version.yml
vendored
@@ -39,4 +39,6 @@ jobs:
|
||||
echo "Start dev build"
|
||||
docker run --privileged --rm tonistiigi/binfmt --install all
|
||||
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
|
||||
|
||||
@@ -39,4 +39,6 @@ jobs:
|
||||
echo "Start productive build"
|
||||
docker run --privileged --rm tonistiigi/binfmt --install all
|
||||
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
|
||||
|
||||
@@ -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.
|
||||
|
||||
* `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`.
|
||||
|
||||
@@ -1308,14 +1308,9 @@ func (a *Api) SetConfiguration(c *gin.Context) {
|
||||
}
|
||||
|
||||
if req.Logging.Level != "" {
|
||||
if req.Logging.Level == "debug" {
|
||||
log.SetLevel(log.DebugLevel)
|
||||
} else if req.Logging.Level == "info" {
|
||||
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"})
|
||||
err = utils.SetLogLevel(req.Logging.Level)
|
||||
if err != nil {
|
||||
c.JSON(400, Error{Msg: err.Error()})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
10
src/main.go
10
src/main.go
@@ -69,6 +69,16 @@ func main() {
|
||||
avatarTmpDir := flag.String("avatar-tmp-dir", "/tmp/", "Avatar tmp directory")
|
||||
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" {
|
||||
docs.SwaggerInfo.Schemes = []string{"http", "https"}
|
||||
} else {
|
||||
|
||||
@@ -3,6 +3,8 @@ package utils
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
"errors"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func GetEnv(key string, defaultVal string) string {
|
||||
@@ -46,3 +48,18 @@ func IsPhoneNumber(s string) bool {
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user