From 3cfa54248ff93654940192df04366a6b273dcca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20MARQUET?= <72651575+BreizhHardware@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:15:01 +0200 Subject: [PATCH 01/10] Add docker-hub compatibility --- .github/workflows/create_release.yml | 51 +++++++++++++++++ CHANGELOG.MD | 3 + Dockerfile | 5 +- README.md | 5 +- entrypoint.sh | 1 + index.html | 77 +++++++++++++++++-------- ntfy.py | 84 ++++++++++++++++++++++++++-- ntfy_api.py | 77 +++++++++++++++++++++++-- script.js | 77 +++++++++++++++++++++++++ test.json | 31 ++++++++++ 10 files changed, 377 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/create_release.yml create mode 100644 CHANGELOG.MD create mode 100644 test.json diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml new file mode 100644 index 0000000..2b395a6 --- /dev/null +++ b/.github/workflows/create_release.yml @@ -0,0 +1,51 @@ +name: Docker Build and Release + +on: + push: + branches: + - main + +jobs: + build-and-release: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ${{ secrets.DOCKER_USERNAME }}/ntfy_alerts:latest + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.sha }} + release_name: Release ${{ github.sha }} + draft: false + prerelease: false + + - name: Upload changelog + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./CHANGELOG.md + asset_name: CHANGELOG.md + asset_content_type: text/markdown \ No newline at end of file diff --git a/CHANGELOG.MD b/CHANGELOG.MD new file mode 100644 index 0000000..0a3e631 --- /dev/null +++ b/CHANGELOG.MD @@ -0,0 +1,3 @@ +**New features**: +- Change database struct to be able to handle docker hub repos +- Now you can add docker hub repo to your watch list diff --git a/Dockerfile b/Dockerfile index cb5d290..ff35da7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,10 +4,11 @@ LABEL maintainer="BreizhHardware" ADD ntfy.py / ADD ntfy_api.py / +ADD migration.py /migration.py / ADD requirements.txt / ADD entrypoint.sh / -ADD index.html /var/www/html/index.html -ADD script.js /var/www/html/script.js +ADD index.html /var/www/html/index.html / +ADD script.js /var/www/html/script.js / RUN apk add --no-cache sqlite-dev sqlite-libs gcc musl-dev nginx RUN pip install -r requirements.txt diff --git a/README.md b/README.md index ea945b5..2e677d8 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ # ntfy_alerts Personal ntfy alerts system -feel free to contribute and to fork +Feel free to contribute and to fork ! # Python ntfy.py ## Description: This script is used to watch the github repos and send a notification to the ntfy server when a new release is published. +It can aloso watch Docker Hub repos and do the same as github. ## Utilisation: auth and ntfy_url are required to be set as environment variables. @@ -44,6 +45,8 @@ Docker Hub repo: https://hub.docker.com/r/breizhhardware/github-ntfy - [x] Add the watched repos list as a parameter - [x] Add the application version as a database - [x] Add the watched repos list as a web interface +- [x] Add Docker Hub compatibility +- [ ] Rework of the web interface # Bash setup-notify.sh ## Description: This script is used to setup the ntfy notification system on ssh login for a new server. diff --git a/entrypoint.sh b/entrypoint.sh index 3940da6..c8db69a 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,4 +7,5 @@ echo -n "$USERNAME:$PASSWORD" | base64 > /auth.txt nginx -g 'daemon off;' & # Exécute le script Python +exec python ./migration.py exec python ./ntfy.py diff --git a/index.html b/index.html index 2156d6f..36eae18 100644 --- a/index.html +++ b/index.html @@ -8,36 +8,69 @@
-