🏡 index : ~doyle/hkbi.git

author Jordan Doyle <jordan@doyle.la> 2022-10-07 0:16:32.0 +00:00:00
committer Jordan Doyle <jordan@doyle.la> 2022-10-07 0:18:42.0 +00:00:00
commit
88020a4eaa9d63624f0554d6c1b422cd779fbb68 [patch]
tree
94ffd78e7dd7c771d298af183af08021b2f846e9
parent
cdfa63a5e79731d1535d0c42e7e3f0f063415789
download
88020a4eaa9d63624f0554d6c1b422cd779fbb68.tar.gz

Start running GitHub actions over repo



Diff

 .github/workflows/ci.yml     | 22 ++++++++++++++++++++++-
 .github/workflows/docker.yml | 45 +++++++++++++++++++++++++++++++++++++++++++++-
 Dockerfile                   | 14 ++++++++++++++-
 blueiris/lib.go              |  1 +-
 cmd/hkbi/main.go             |  3 +--
 5 files changed, 83 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..133a320
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,22 @@
on: ["push", "pull_request"]

name: "CI"

jobs:
  ci:
    name: "Run CI"
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-go@v3
        with:
          go-version: '^1.19.0'
          check-latest: true
          cache: true
      - run: "go version"
      - run: "go test ./..."
      - run: "go vet ./..."
      - uses: dominikh/staticcheck-action@v1.2.0
        with:
          version: "2022.1"
          install-go: false
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
new file mode 100644
index 0000000..f0032ee
--- /dev/null
+++ b/.github/workflows/docker.yml
@@ -0,0 +1,45 @@
name: Build Docker image

on:
  push:
    branches: [ master ]
    tags: [ 'v*.*.*' ]
  pull_request:
    branches: [ master ]

env:
  REGISTRY: ghcr.io

jobs:
  build-and-push:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write

    steps:
      - name: Checkout repository
        uses: actions/checkout@v3
      - name: Setup Docker buildx
        uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
      - name: Log into registry ${{ env.REGISTRY }}
        if: github.event_name != 'pull_request'
        uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - name: Extract Docker metadata
        id: meta
        uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
        with:
          images: ${{ env.REGISTRY }}/w4/hkbi
      - name: Build and push
        id: build-and-push
        uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
        with:
          context: .
          file: ./Dockerfile
          push: ${{ github.event_name != 'pull_request' }}
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..3b5a7da
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,14 @@
# syntax=docker/dockerfile:1
FROM golang:1.19.2-bullseye AS build
WORKDIR /build
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
RUN go build -o hkbi cmd/hkbi/main.go

FROM debian:bullseye
LABEL org.opencontainers.image.source="https://github.com/w4/hkbi"
WORKDIR /app
COPY --from=build /build/hkbi /app/hkbi
CMD ["/app/hkbi", "/data/config.toml"]
diff --git a/blueiris/lib.go b/blueiris/lib.go
index 5384a6e..0ff7d75 100644
--- a/blueiris/lib.go
+++ b/blueiris/lib.go
@@ -132,6 +132,7 @@ func (b *Blueiris) ListCameras() ([]Camera, error) {
	return response.Data, nil
}

//lint:ignore U1000 usage not yet implemented
func (b *Blueiris) triggerCamera(camera string) error {
	b.mutex.RLock()
	defer b.mutex.RUnlock()
diff --git a/cmd/hkbi/main.go b/cmd/hkbi/main.go
index abc2559..4951b78 100644
--- a/cmd/hkbi/main.go
+++ b/cmd/hkbi/main.go
@@ -38,7 +38,6 @@ type Config struct {
type GlobalState struct {
	ssrcVideo int32
	ssrcAudio int32
	blueiris  *blueiris.Blueiris
}

func main() {
@@ -289,7 +288,7 @@ func run(config Config) {
	})

	// set up a listener for sigint and sigterm signals to stop the server
	c := make(chan os.Signal)
	c := make(chan os.Signal, 1)
	signal.Notify(c, os.Interrupt)
	signal.Notify(c, syscall.SIGTERM)