Skip to content

Commit

Permalink
Merge branch 'master' into upstream-to-pr/rev-ce2e6e0
Browse files Browse the repository at this point in the history
  • Loading branch information
fopina committed Jul 3, 2024
2 parents ce2e6e0 + 2253ef5 commit 1c6c048
Show file tree
Hide file tree
Showing 14 changed files with 222 additions and 117 deletions.
19 changes: 9 additions & 10 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: 🔨 Build Test
on:
push:
branches:
- master
pull_request:
workflow_dispatch:

Expand Down Expand Up @@ -33,13 +36,9 @@ jobs:
run: go build .
working-directory: cmd/notify/

- name: Integration Tests
env:
DISCORD_WEBHOOK_URL: "${{ secrets.DISCORD_WEBHOOK_URL }}"
SLACK_WEBHOOK_URL: "${{ secrets.SLACK_WEBHOOK_URL }}"
CUSTOM_WEBHOOK_URL: "${{ secrets.CUSTOM_WEBHOOK_URL }}"
run: |
chmod +x gotify.sh
chmod +x action-run.sh
bash action-run.sh
working-directory: cmd/integration-test/
# - name: Integration Tests
# run: |
# chmod +x gotify.sh
# chmod +x action-run.sh
# bash action-run.sh
# working-directory: cmd/integration-test/
38 changes: 0 additions & 38 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

40 changes: 0 additions & 40 deletions .github/workflows/dockerhub-push.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: 🙏🏻 Lint Test

on:
push:
branches:
- master
pull_request:
paths:
- '**.go'
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/merge_upstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: auto update

on:
schedule:
- cron: "0 12 * * *"
workflow_dispatch:
inputs: {}

jobs:
autoupdate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.PAT }}
- uses: fopina/upstream-to-pr@v1
with:
token: ${{ secrets.PAT }}
upstream-repository: https://github.com/projectdiscovery/notify
upstream-tag: v\d+\.\d+\.\d+
9 changes: 6 additions & 3 deletions .github/workflows/release-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ jobs:
with:
go-version: 1.21.x

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: "Create release on GitHub"
uses: goreleaser/goreleaser-action@v4
with:
Expand All @@ -28,6 +34,3 @@ jobs:
workdir: .
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
SLACK_WEBHOOK: "${{ secrets.RELEASE_SLACK_WEBHOOK }}"
DISCORD_WEBHOOK_ID: "${{ secrets.DISCORD_WEBHOOK_ID }}"
DISCORD_WEBHOOK_TOKEN: "${{ secrets.DISCORD_WEBHOOK_TOKEN }}"
2 changes: 1 addition & 1 deletion .github/workflows/release-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
release-test:
runs-on: ubuntu-latest-16-cores
runs-on: ubuntu-latest
steps:
- name: "Check out code"
uses: actions/checkout@v3
Expand Down
43 changes: 34 additions & 9 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ builds:
- arm
- arm64

goarm:
- '7'

ignore:
- goos: darwin
goarch: '386'
Expand All @@ -31,13 +34,35 @@ archives:
checksum:
algorithm: sha256

announce:
slack:
enabled: true
channel: '#release'
username: GoReleaser
message_template: 'New Release: {{ .ProjectName }} {{.Tag}} is published! Check it out at {{ .ReleaseURL }}'
dockers:
- &image-def
image_templates:
- fopina/{{.ProjectName}}:{{ .Version }}-amd64
use: buildx
goos: linux
goarch: amd64
build_flag_templates:
- --platform=linux/amd64
- <<: *image-def
image_templates:
- fopina/{{.ProjectName}}:{{ .Version }}-arm64
goarch: arm64
build_flag_templates:
- --platform=linux/arm64/v8
- <<: *image-def
image_templates:
- fopina/{{.ProjectName}}:{{ .Version }}-armv7
goarch: arm
goarm: '7'
build_flag_templates:
- --platform=linux/arm/v7

discord:
enabled: true
message_template: '**New Release: {{ .ProjectName }} {{.Tag}}** is published! Check it out at {{ .ReleaseURL }}'
docker_manifests:
- &manifest-def
name_template: fopina/{{.ProjectName}}:{{ .Version }}
image_templates:
- fopina/{{.ProjectName}}:{{ .Version }}-armv7
- fopina/{{.ProjectName}}:{{ .Version }}-arm64
- fopina/{{.ProjectName}}:{{ .Version }}-amd64
- <<: *manifest-def
name_template: fopina/{{.ProjectName}}:latest
14 changes: 2 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
# Base
FROM golang:1.21.4-alpine AS builder
RUN apk add --no-cache build-base
WORKDIR /app
COPY . /app
RUN go mod download
RUN go build ./cmd/notify
FROM alpine:latest

# Release
FROM alpine:3.18.2
RUN apk -U upgrade --no-cache \
&& apk add --no-cache bind-tools ca-certificates
COPY --from=builder /app/notify /usr/local/bin/
COPY notify /usr/local/bin/notify

ENTRYPOINT ["notify"]
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,42 @@ Notify is a Go-based assistance package that enables you to stream the output of
<br>
</h1>

# THIS FORK

This fork implements a `-web` flag (until a it is cleaned up and a PR can be created)

## Web

In some restricted (container?) environments it might be useful to have a single notify installation (and configuration) available for multiple services/scripts to use it.

`-web` starts a local webserver and anything POSTed to that URL will be pushed as if it was stdin.

```
$ notify -web
Up and running!
Post raw data to http://127.0.0.1:8888/, as in:
curl http://127.0.0.1:8888/ -d 'testing 1 2 3'
This will send that data as message using all profiles.
To use a specific one, post to http://127.0.0.1:8888/PROFILE
```

## Docker

`-web` mode is specially useful in a cluster of containers so that notify does not need to be installed and configured in every image.

An image is ready to be used in [the hub](https://hub.docker.com/r/fopina/notify):

```
$ docker run --rm \
-v ~/.providers.conf:/.providers.conf:ro \
-p 8888:8888 \
fopina/notify \
-w -b 0.0.0.0:8888 -pc /.providers.conf
```

# Features

- Supports for Slack / Discord / Telegram
Expand Down
8 changes: 7 additions & 1 deletion cmd/notify/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ func main() {
}()
}()

err = notifyRunner.Run()
if options.Web {
err = notifyRunner.StartWeb()
} else {
err = notifyRunner.Run()
}
if err != nil {
gologger.Fatal().Msgf("Could not run notifier: %s\n", err)
}
Expand All @@ -66,6 +70,8 @@ func readConfig() {
set.StringVar(&options.Proxy, "proxy", "", "HTTP Proxy to use with notify")
set.CallbackVarP(runner.GetUpdateCallback(), "update", "up", "update notify to latest version")
set.BoolVarP(&options.DisableUpdateCheck, "disable-update-check", "duc", false, "disable automatic notify update check")
set.StringVar(&options.WebBind, "web-bind", "127.0.0.1:8888", "Address and port to bind web server")
set.BoolVar(&options.Web, "web", false, "Run as webserver, using raw POST data as message")

_ = set.Parse()

Expand Down
Loading

0 comments on commit 1c6c048

Please sign in to comment.