diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..b424659b --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,29 @@ +name: Deploy Master Release +on: deployment + +jobs: + docker-release: + needs: upload-release + runs-on: ubuntu-latest + steps: + - name: Checkout Statping Repo + uses: actions/checkout@v2 + + - name: Setting ENV's + run: echo ::set-env name=VERSION::$(cat version.txt) + shell: bash + + - name: Set up Docker Buildx + uses: crazy-max/ghaction-docker-buildx@v3 + + - name: Docker Login + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + run: echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin + + - name: Docker Buildx (push) + run: | + docker buildx create --use + docker buildx build --tag=statping/statping,statping/statping:v${VERSION} --build-arg=VERSION=${VERSION} --platform=linux/amd64,linux/386,linux/arm64,linux/arm/v7 --output type=image,name=docker.io/statping/statping,push=true . + diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 7ad19d81..8d471e8e 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -5,6 +5,11 @@ on: - dev paths-ignore: - '**.md' + pull_request: + branches: + - dev + paths-ignore: + - '**.md' jobs: compile: @@ -136,6 +141,8 @@ jobs: TWILIO_FROM: ${{ secrets.TWILIO_FROM }} TWILIO_TO: ${{ secrets.TWILIO_TO }} TEST_EMAIL: ${{ secrets.TEST_EMAIL }} + GOTIFY_URL: ${{ secrets.GOTIFY_URL }} + GOTIFY_TOKEN: ${{ secrets.GOTIFY_TOKEN }} - name: Coveralls Testing Coverage run: | @@ -310,25 +317,16 @@ jobs: run: echo ::set-env name=VERSION::$(cat version.txt) shell: bash - - name: Base Docker Image - uses: elgohr/Publish-Docker-Github-Action@master - with: - name: statping/statping - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - dockerfile: Dockerfile.base - tags: "base" + - name: Set up Docker Buildx + uses: crazy-max/ghaction-docker-buildx@v3 - - name: Dev Docker Image - uses: elgohr/Publish-Docker-Github-Action@master + - name: Docker Login env: - VERSION: ${{ env.VERSION }} - ARCH: amd64 - DOCKER_CLI_EXPERIMENTAL: enabled - with: - name: statping/statping - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - dockerfile: Dockerfile - tags: "dev" - buildargs: VERSION,ARCH + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + run: echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin + + - name: Docker Buildx (push) + run: | + docker buildx create --use + docker buildx build --tag=statping/statping:dev --build-arg=VERSION=${VERSION} --platform=linux/amd64,linux/386,linux/arm64,linux/arm/v7 --output type=image,name=docker.io/statping/statping,push=true . diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 38fbb862..d03e367a 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -5,6 +5,9 @@ on: - master paths-ignore: - '**.md' + pull_request: + branches: + - master jobs: compile: @@ -136,6 +139,8 @@ jobs: TWILIO_FROM: ${{ secrets.TWILIO_FROM }} TWILIO_TO: ${{ secrets.TWILIO_TO }} TEST_EMAIL: ${{ secrets.TEST_EMAIL }} + GOTIFY_URL: ${{ secrets.GOTIFY_URL }} + GOTIFY_TOKEN: ${{ secrets.GOTIFY_TOKEN }} - name: Coveralls Testing Coverage run: | @@ -401,40 +406,6 @@ jobs: builds/statping-windows-amd64.zip builds/statping-windows-arm.zip - docker-release: - needs: upload-release - runs-on: ubuntu-latest - steps: - - name: Checkout Statping Repo - uses: actions/checkout@v2 - - - name: Setting ENV's - run: echo ::set-env name=VERSION::$(cat version.txt) - shell: bash - - - name: Base Docker Image - uses: elgohr/Publish-Docker-Github-Action@master - with: - name: statping/statping - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - dockerfile: Dockerfile.base - tags: "base" - - - name: Latest/Version Docker Image - uses: elgohr/Publish-Docker-Github-Action@master - env: - VERSION: ${{ env.VERSION }} - ARCH: amd64 - DOCKER_CLI_EXPERIMENTAL: enabled - with: - name: statping/statping - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - dockerfile: Dockerfile - tags: "latest,v${{ env.VERSION }}" - buildargs: VERSION,ARCH - sentry-release: needs: upload-release runs-on: ubuntu-latest diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 7602ac04..ed8ec36f 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -5,9 +5,7 @@ on: - '*' # matches every branch - '*/*' # matches every branch containing a single '/' - '!master' # excludes master - pull_request: - branches: - - dev + - '!dev' # excludes dev jobs: compile: diff --git a/CHANGELOG.md b/CHANGELOG.md index ed5d2c48..022fbfbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 0.90.58 (07-09-2020) +- Fixed ICMP latency/ping durations +- Fixed webhook notifier +- Modified file structure for Vue admin dashboard components. +- Added Gotify notifier + # 0.90.57 (07-04-2020) - Fixed login issue diff --git a/Makefile b/Makefile index 98721fcc..4a0bf99a 100644 --- a/Makefile +++ b/Makefile @@ -331,5 +331,9 @@ certs: -keyout key.pem \ -subj "/C=US/ST=California/L=Santa Monica/O=Statping/OU=Development/CN=localhost" -.PHONY: all build build-all build-alpine test-all test test-api docker frontend up down print_details lite sentry-release snapcraft build-linux build-mac build-win build-all postman +buildx: + docker buildx create --use + docker buildx build --tag=statping/statping:dev --build-arg=VERSION=${VERSION} --platform=linux/amd64,linux/386,linux/arm64,linux/arm/v7 --output type=image,name=docker.io/statping/statping,push=true . + +.PHONY: all build build-all buildx build-alpine test-all test test-api docker frontend up down print_details lite sentry-release snapcraft build-linux build-mac build-win build-all postman .SILENT: travis_s3_creds diff --git a/cmd/cli.go b/cmd/cli.go index 672fb676..b28140fb 100644 --- a/cmd/cli.go +++ b/cmd/cli.go @@ -153,8 +153,10 @@ func onceCli() error { func importCli(args []string) error { var err error var data []byte - filename := args[1] - if data, err = ioutil.ReadFile(filename); err != nil { + if len(args) < 1 { + return errors.New("invalid command arguments") + } + if data, err = ioutil.ReadFile(args[0]); err != nil { return err } var exportData ExportData @@ -162,11 +164,40 @@ func importCli(args []string) error { return err } log.Printf("=== %s ===\n", exportData.Core.Name) - log.Printf("Services: %d\n", len(exportData.Services)) - log.Printf("Checkins: %d\n", len(exportData.Checkins)) - log.Printf("Groups: %d\n", len(exportData.Groups)) - log.Printf("Messages: %d\n", len(exportData.Messages)) - log.Printf("Users: %d\n", len(exportData.Users)) + if exportData.Config != nil { + log.Printf("Configs: %s\n", exportData.Config.DbConn) + if exportData.Config.DbUser != "" { + log.Printf(" - Host: %s\n", exportData.Config.DbHost) + log.Printf(" - User: %s\n", exportData.Config.DbUser) + } + } + if len(exportData.Services) > 0 { + log.Printf("Services: %d\n", len(exportData.Services)) + } + if len(exportData.Checkins) > 0 { + log.Printf("Checkins: %d\n", len(exportData.Checkins)) + } + if len(exportData.Groups) > 0 { + log.Printf("Groups: %d\n", len(exportData.Groups)) + } + if len(exportData.Messages) > 0 { + log.Printf("Messages: %d\n", len(exportData.Messages)) + } + if len(exportData.Users) > 0 { + log.Printf("Users: %d\n", len(exportData.Users)) + } + + if exportData.Config != nil { + if ask("Create config.yml file from Configs?") { + log.Printf("Database Host: %s\n", exportData.Config.DbHost) + log.Printf("Database Port: %d\n", exportData.Config.DbPort) + log.Printf("Database User: %s\n", exportData.Config.DbUser) + log.Printf("Database Password: %s\n", exportData.Config.DbPass) + if err := exportData.Config.Save(utils.Directory); err != nil { + return err + } + } + } config, err := configs.LoadConfigs(configFile) if err != nil { @@ -175,8 +206,10 @@ func importCli(args []string) error { if err = configs.ConnectConfigs(config, false); err != nil { return err } - if data, err = ExportSettings(); err != nil { - return fmt.Errorf("could not export settings: %v", err.Error()) + if ask("Create database rows and sample data?") { + if err := config.ResetCore(); err != nil { + return err + } } if ask("Import Core settings?") { @@ -221,7 +254,7 @@ func importCli(args []string) error { if ask(fmt.Sprintf("Import User '%s'?", s.Username)) { s.Id = 0 if err := s.Create(); err != nil { - return err + log.Errorln(err) } } } @@ -376,6 +409,7 @@ type gitUploader struct { // ExportChartsJs renders the charts for the index page type ExportData struct { + Config *configs.DbConfig `json:"config"` Core *core.Core `json:"core"` Services []services.Service `json:"services"` Messages []*messages.Message `json:"messages"` @@ -403,7 +437,14 @@ func ExportSettings() ([]byte, error) { s.Failures = nil srvs = append(srvs, s) } + + cfg, err := configs.LoadConfigs(configFile) + if err != nil { + return nil, err + } + data := ExportData{ + Config: cfg, Core: c, Notifiers: core.App.Notifications, Checkins: checkins.All(), diff --git a/cmd/main.go b/cmd/main.go index 87c2d72e..056202fe 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -96,39 +96,8 @@ func start() { exit(err) } - if !confgs.Db.HasTable("core") { - var srvs int64 - if confgs.Db.HasTable(&services.Service{}) { - confgs.Db.Model(&services.Service{}).Count(&srvs) - if srvs > 0 { - exit(errors.Wrap(err, "there are already services setup.")) - return - } - } - - if err := confgs.DropDatabase(); err != nil { - exit(errors.Wrap(err, "error dropping database")) - } - - if err := confgs.CreateDatabase(); err != nil { - exit(errors.Wrap(err, "error creating database")) - } - - if err := configs.CreateAdminUser(confgs); err != nil { - exit(errors.Wrap(err, "error creating default admin user")) - } - - if utils.Params.GetBool("SAMPLE_DATA") { - log.Infoln("Adding Sample Data") - if err := configs.TriggerSamples(); err != nil { - exit(errors.Wrap(err, "error adding sample data")) - } - } else { - if err := core.Samples(); err != nil { - exit(errors.Wrap(err, "error added core details")) - } - } - + if err = confgs.ResetCore(); err != nil { + exit(err) } if err = confgs.DatabaseChanges(); err != nil { diff --git a/dev/postman.json b/dev/postman.json index 1f6b4ba6..024a483f 100644 --- a/dev/postman.json +++ b/dev/postman.json @@ -3917,7 +3917,7 @@ "", "pm.test(\"View All Notifiers\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.length).to.eql(11);", + " pm.expect(jsonData.length).to.eql(12);", "});" ], "type": "text/javascript" diff --git a/frontend/src/components/Dashboard/DashboardIndex.vue b/frontend/src/components/Dashboard/DashboardIndex.vue index 8049883e..e8290888 100644 --- a/frontend/src/components/Dashboard/DashboardIndex.vue +++ b/frontend/src/components/Dashboard/DashboardIndex.vue @@ -23,7 +23,7 @@