From a2f7ccd7723e111d369677b98375458e49ec7a83 Mon Sep 17 00:00:00 2001 From: Devin Buhl Date: Sat, 13 Mar 2021 11:11:41 -0500 Subject: [PATCH] switch to ghcr, major updates to workflows --- .github/ISSUE_TEMPLATE/bug.md | 26 ++++++++++ .github/ISSUE_TEMPLATE/config.yml | 10 ++++ .github/ISSUE_TEMPLATE/enhancement.md | 22 ++++++++ .github/PAUL.yaml | 15 ++++++ .github/PULL_REQUEST_TEMPLATE.md | 32 ++++++++++++ .github/stale.yml | 32 ++++++++++++ .github/workflows/ci.yml | 64 ++++++++++++++++++++++++ .github/workflows/main.yml | 34 ------------- .github/workflows/release.yml | 50 ++++++++++++++++++ README.md | 25 ++++----- build/package/Dockerfile | 37 +++++++++----- examples/compose/docker-compose.yaml | 12 ++--- examples/kubernetes/radarr-exporter.yaml | 7 +-- examples/kubernetes/sonarr-exporter.yaml | 7 +-- 14 files changed, 302 insertions(+), 71 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug.md create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/enhancement.md create mode 100644 .github/PAUL.yaml create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/stale.yml create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md new file mode 100644 index 0000000..317374b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -0,0 +1,26 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: kind:bug +assignees: '' + +--- + +# Details + +**What steps did you take and what happened:** + + + +**What did you expect to happen:** + + + +**Anything else you would like to add:** + + + +**Additional Information:** + + diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..0055bb1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,10 @@ +--- + +blank_issues_enabled: false +contact_links: +- name: Discuss on GitHub + url: https://github.com/k8s-at-home/organization/discussions + about: Ask and answer questions here +- name: Discuss on Discord + url: https://discord.com/invite/sTMX7Vh + about: Join our Discord community diff --git a/.github/ISSUE_TEMPLATE/enhancement.md b/.github/ISSUE_TEMPLATE/enhancement.md new file mode 100644 index 0000000..a5f93fc --- /dev/null +++ b/.github/ISSUE_TEMPLATE/enhancement.md @@ -0,0 +1,22 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: kind:enhancement +assignees: '' + +--- + +# Details + +**Describe the solution you'd like:** + + + +**Anything else you would like to add:** + + + +**Additional Information:** + + diff --git a/.github/PAUL.yaml b/.github/PAUL.yaml new file mode 100644 index 0000000..8644fbe --- /dev/null +++ b/.github/PAUL.yaml @@ -0,0 +1,15 @@ +maintainers: +- onedr0p +labels: true +empty_description_check: + enabled: true + enforced: false +branch_destroyer: + enabled: true + protected_branches: + - master +pull_requests: + automated_merge: false + cats_enabled: true + dogs_enabled: true + allow_approval: true diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..742a086 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,32 @@ + + +**Description of the change** + + + +**Benefits** + + + +**Possible drawbacks** + + + +**Applicable issues** + + +- fixes # + +**Additional information** + + diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000..616be95 --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,32 @@ +# Configuration for probot-stale - https://github.com/probot/stale + +# Number of days of inactivity before an Issue or Pull Request becomes stale +daysUntilStale: 45 + +# Number of days of inactivity before a stale Issue or Pull Request is closed. +daysUntilClose: 5 + +# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable +exemptLabels: +- on-hold +- pinned + +# Label to use when marking as stale +staleLabel: stale + +issues: + # Comment to post when marking as stale. Set to `false` to disable + markComment: > + This Issue has been automatically marked as "stale" because it has not had recent activity (for 45 days). It will be closed if no further activity occurs. Thanks for the feedback. + # Comment to post when closing a stale Issue or Pull Request. + closeComment: > + Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary. +pulls: + # Comment to post when marking as stale. Set to `false` to disable + markComment: > + This Pull Request has been automatically marked as "stale" because it has not had recent activity (for 45 days). It will be closed if no further activity occurs. Thank you for your contribution. + # Comment to post when closing a stale Issue or Pull Request. + closeComment: > + Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Pull Request. Do not hesitate to reopen it later if necessary. +# Limit the number of actions per hour, from 1-30. Default is 30 +limitPerRun: 30 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1eff507 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,64 @@ +name: ci + +on: + push: + branches: + - master + pull_request: + types: + - opened + - reopened + +env: + REGISTRY_IMAGE: ghcr.io/onedr0p/exportarr + +jobs: + build: + runs-on: ubuntu-20.04 + if: "!contains(github.event.head_commit.message, '[ci-skip]')" + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + with: + platforms: all + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + with: + install: true + version: latest + driver-opts: image=moby/buildkit:master + + - name: Login to GitHub Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ secrets.GHCR_USERNAME }} + password: ${{ secrets.GHCR_TOKEN }} + + - name: Build and Push (PR) + if: github.event_name == 'pull_request' + uses: docker/build-push-action@v2 + with: + context: . + file: ./build/package/Dockerfile + platforms: linux/amd64,linux/arm/v7,linux/arm64 + push: false # GitHub secrets not available in PRs + tags: | + ghcr.io/${{ github.repository_owner }}/pull-request:${{github.event.number}} + + - name: Build and Push (master branch) + if: github.event_name != 'pull_request' + uses: docker/build-push-action@v2 + with: + context: . + file: ./build/package/Dockerfile + platforms: linux/amd64,linux/arm/v7,linux/arm64 + push: true + tags: | + ${{ env.REGISTRY_IMAGE }}:${GITHUB_REF##*/} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index a32757d..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: main -on: - push: - branches: - - master - tags: - - v* -jobs: - master: - if: "!contains(github.event.head_commit.message, '[ci-skip]')" - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up Docker Buildx - id: buildx - uses: crazy-max/ghaction-docker-buildx@v1 - with: - version: latest - - - name: Login to GitHub Docker Registry - run: echo "${DOCKERHUB_PASSWORD}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin - env: - DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} - - - name: Build Container Image - run: | - docker buildx build \ - -t onedr0p/exportarr:${GITHUB_REF##*/} \ - --platform linux/amd64,linux/arm/v7,linux/arm64 \ - -f ./build/package/Dockerfile \ - --push . diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3a1d514 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,50 @@ +name: release + +on: + push: + tags: + - v*.*.* + +env: + REGISTRY_IMAGE: ghcr.io/onedr0p/exportarr + +jobs: + build: + runs-on: ubuntu-20.04 + if: "!contains(github.event.head_commit.message, '[ci-skip]')" + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + with: + platforms: all + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + with: + install: true + version: latest + driver-opts: image=moby/buildkit:master + + - name: Login to GitHub Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ secrets.GHCR_USERNAME }} + password: ${{ secrets.GHCR_TOKEN }} + + - name: Build and Push + if: github.event_name != 'pull_request' + uses: docker/build-push-action@v2 + with: + context: . + file: ./build/package/Dockerfile + platforms: linux/amd64,linux/arm/v7,linux/arm64 + push: true + tags: | + ${{ env.REGISTRY_IMAGE }}:latest + ${{ env.REGISTRY_IMAGE }}:${GITHUB_REF##*/} diff --git a/README.md b/README.md index 35b2dcc..7efbc61 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ AIO Prometheus Exporter for Sonarr, Radarr or Lidarr(TBD) -[![Docker Pulls](https://img.shields.io/docker/pulls/onedr0p/exportarr)](https://hub.docker.com/r/onedr0p/exportarr) [![Go Report Card](https://goreportcard.com/badge/github.com/onedr0p/exportarr)](https://goreportcard.com/report/github.com/onedr0p/exportarr) This is Prometheus Exporter will export metrics gathered from Sonarr or Radarr. This only supports v3 APIs for Sonarr and Radarr. It will not gather metrics from all 3 at once, and instead you need to tell the exporter what metrics you want. Be sure to see the examples below for more information. @@ -15,13 +14,13 @@ See examples in the [examples/compose](./examples/compose/) directory ### Run with Kubernetes -See examples in the [examples/kubernetes](./examples/kubernetes/) directory, or use the [billimek-charts/sonarr](https://github.com/billimek/billimek-charts/tree/master/charts/sonarr) or [billimek-charts/radarr](https://github.com/billimek/billimek-charts/tree/master/charts/radarr) Helm charts. +See examples in the [examples/kubernetes](./examples/kubernetes/) directory. ### Run with Docker CLI #### Sonarr ```bash -sudo docker run --name exportarr_sonarr \ +docker run --name exportarr_sonarr \ --entrypoint "exportarr" \ -e port=9707 \ -e URL="http://192.168.1.1:8989" \ @@ -29,7 +28,7 @@ sudo docker run --name exportarr_sonarr \ -e ENABLE_EPISODE_QUALITY_METRICS="false" \ --restart unless-stopped \ -p 9707:9707 \ - -d onedr0p/exportarr:master sonarr + -d ghcr.io/onedr0p/exportarr:latest sonarr ``` Visit http://127.0.0.1:9707/metrics to see Sonarr metrics @@ -37,29 +36,29 @@ Visit http://127.0.0.1:9707/metrics to see Sonarr metrics #### Radarr ```bash -sudo docker run --name exportarr_radarr \ +docker run --name exportarr_radarr \ --entrypoint "exportarr" \ -e port=9708 \ -e URL="http://192.168.1.1:7878" \ - -e APIKEY="amlmndfb503rfqaa5ln5hj5qkmu3hy18" \ + -e APIKEY="zmlmndfb503rfqaa5ln5hj5qkmu3hy19" \ --restart unless-stopped \ -p 9708:9708 \ - -d onedr0p/exportarr:master sonarr + -d ghcr.io/onedr0p/exportarr:latest sonarr ``` Visit http://127.0.0.1:9708/metrics to see Radarr metrics ### Run from the CLI -```cmd +```sh ./exportarr --help -./exportarr sonarr --help -./exportarr radarr --help ``` #### Sonarr -```cmd +```sh +./exportarr sonarr --help + ./exportarr sonarr \ --port 9707 \ --url http://127.0.0.1:8989 \ @@ -71,7 +70,9 @@ Visit http://127.0.0.1:9707/metrics to see Sonarr metrics #### Radarr -```cmd +```sh +./exportarr radarr --help + ./exportarr radarr \ --port 9708 \ --url http://127.0.0.1:7878 \ diff --git a/build/package/Dockerfile b/build/package/Dockerfile index bf89de7..23928b9 100644 --- a/build/package/Dockerfile +++ b/build/package/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.14-alpine as build +FROM golang:1.16-alpine as build ENV GO111MODULE=on \ CGO_ENABLED=0 @@ -7,19 +7,32 @@ WORKDIR /build COPY . . -RUN apk --no-cache add ca-certificates \ - && export GOOS=$(echo ${TARGETPLATFORM} | cut -d / -f1) \ - && export GOARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \ - && GOARM=$(echo ${TARGETPLATFORM} | cut -d / -f3); export GOARM=${GOARM:1} \ - && go mod download \ - && go build -a -tags netgo -ldflags '-w -extldflags "-static"' -o exportarr /build/cmd/exportarr/. \ - && chmod +x exportarr +RUN \ + export GOOS=$(echo ${TARGETPLATFORM} | cut -d / -f1) \ + && \ + export GOARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \ + && \ + GOARM=$(echo ${TARGETPLATFORM} | cut -d / -f3); export GOARM=${GOARM:1} \ + && \ + go mod download \ + && \ + go build -a -tags netgo -ldflags '-w -extldflags "-static"' -o exportarr /build/cmd/exportarr/. \ + && \ + chmod +x exportarr -FROM gcr.io/distroless/static:nonroot +FROM apline:3.13 ENV PORT="9707" -COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +RUN \ + apk add --no-cache \ + ca-certificates \ + tzdata \ + tini \ + && \ + addgroup -S exportarr && adduser -S exportarr -G exportarr + COPY --from=build /build/exportarr /usr/local/bin/exportarr -USER nonroot:nonroot -ENTRYPOINT ["exportarr"] +USER exportarr:exportarr +ENTRYPOINT [ "/sbin/tini", "--" ] +CMD [ "exportarr" ] diff --git a/examples/compose/docker-compose.yaml b/examples/compose/docker-compose.yaml index d1c91c8..57605a8 100644 --- a/examples/compose/docker-compose.yaml +++ b/examples/compose/docker-compose.yaml @@ -2,9 +2,8 @@ version: "3.7" services: sonarr-exporter: - image: onedr0p/exportarr:master - entrypoint: ["exportarr"] - command: ["sonarr"] + image: ghcr.io/onedr0p/exportarr:latest + command: ["exportarr", "sonarr"] environment: PORT: 9707 URL: "http://192.168.1.100:8989" @@ -13,12 +12,11 @@ services: ports: - "9707:9707" radarr-exporter: - image: onedr0p/exportarr:master - entrypoint: ["exportarr"] - command: ["radarr"] + image: ghcr.io/onedr0p/exportarr:latest + command: ["exportarr", "radarr"] environment: PORT: 9708 URL: "http://192.168.1.100:7878" - APIKEY: "amlmndfb503rfqaa5ln5hj5qkmu3hy18" + APIKEY: "zmlmndfb503rfqaa5ln5hj5qkmu3hy19" ports: - "9708:9708" diff --git a/examples/kubernetes/radarr-exporter.yaml b/examples/kubernetes/radarr-exporter.yaml index 26a22e1..5fcd12a 100644 --- a/examples/kubernetes/radarr-exporter.yaml +++ b/examples/kubernetes/radarr-exporter.yaml @@ -61,10 +61,11 @@ spec: spec: containers: - name: radarr-exporter - image: onedr0p/exportarr:master + image: ghcr.io/onedr0p/exportarr:latest imagePullPolicy: Always - command: ["exportarr"] - args: ["radarr"] + args: + - exportarr + - radarr env: - name: PORT value: "9708" diff --git a/examples/kubernetes/sonarr-exporter.yaml b/examples/kubernetes/sonarr-exporter.yaml index 66a2c3b..4207195 100644 --- a/examples/kubernetes/sonarr-exporter.yaml +++ b/examples/kubernetes/sonarr-exporter.yaml @@ -65,10 +65,11 @@ spec: spec: containers: - name: sonarr-exporter - image: onedr0p/exportarr:master + image: ghcr.io/onedr0p/exportarr:latest imagePullPolicy: Always - command: ["exportarr"] - args: ["sonarr"] + args: + - exportarr + - sonarr env: - name: PORT value: "9707"