Skip to content

Commit

Permalink
v.1.2.1 - Dependency Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rix1337 authored and rix committed May 19, 2024
1 parent 477f8f8 commit 7ec38bb
Show file tree
Hide file tree
Showing 21 changed files with 239 additions and 82 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/BuildImage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Build Image

on:
workflow_dispatch:
inputs:
version:
default: 'false'
description: 'Version to build'
required: false

env:
ENDPOINT: "rix1337/docker-myjd-api"

jobs:
version-check:
runs-on: ubuntu-latest
outputs:
output: ${{ steps.get-version.outputs.version }}
steps:
- id: get-version
run: |
if [ -z "${{ github.event.inputs.version }}" ]; then VS="false"; else VS=${{ github.event.inputs.version }}; fi
if [[ ${VS} == "false" ]]
then
echo "Grabbing latest myjd-api version from pypi.org"
VERSION=$(curl -Ls https://pypi.org/pypi/myjd-api/json | jq -r .info.version)
else
echo "Using version from workflow_dispatch input"
VERSION=${VS}
fi
echo $VERSION
echo "version=$VERSION" >>$GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
needs: version-check
steps:
- uses: actions/checkout@v4
- uses: whoan/docker-build-with-cache-action@v6
id: firstrun
continue-on-error: true
with:
username: "${{ secrets.DOCKERUSER }}"
password: "${{ secrets.DOCKERPASS }}"
image_name: "${{ env.ENDPOINT }}"
image_tag: latest,${{needs.version-check.outputs.output}}
context: "./docker"
stages_image_name: "rix1337/cache-myjd-api-latest"
build_extra_args: "--build-arg=VS=${{needs.version-check.outputs.output}}"
- name: Sleep before retry
if: steps.firstrun.outcome=='failure'
uses: jakejarvis/wait-action@master
with:
time: '1m'
- uses: whoan/docker-build-with-cache-action@v6
if: steps.firstrun.outcome=='failure'
with:
username: "${{ secrets.DOCKERUSER }}"
password: "${{ secrets.DOCKERPASS }}"
image_name: "${{ env.ENDPOINT }}"
image_tag: latest,${{needs.version-check.outputs.output}}
context: "./docker"
stages_image_name: "rix1337/cache-myjd-api-latest"
build_extra_args: "--build-arg=VS=${{needs.version-check.outputs.output}}"
13 changes: 8 additions & 5 deletions .github/workflows/CreateRelease.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
name: Release Artifacts

on:
on:
push:
paths-ignore:
- '.github/**'
- 'docker/**'
branches:
- main

Expand All @@ -11,8 +14,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: actions/cache@v3
uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}-${{ hashFiles('setup.py') }}
Expand All @@ -27,7 +30,7 @@ jobs:
run: |
python setup.py sdist bdist_wheel
- name: Get Version
run: echo "version=$(python myjd_api/version.py)" >>$GITHUB_OUTPUT
run: echo "version=$(python myjd_api/providers/version.py)" >>$GITHUB_OUTPUT
id: version
- name: Create Release
uses: ncipollo/release-action@v1
Expand All @@ -41,4 +44,4 @@ jobs:
python -m twine upload ./dist/* -u __token__ -p ${{ secrets.PYPI_TOKEN }}
- name: Trigger Docker Image build
run: |
curl -XPOST -u "${{ secrets.CR_USER }}:${{secrets.CR_PAT}}" -H "Accept: application/vnd.github.v3+json" -H "Content-Type: application/json" https://api.github.com/repos/rix1337/docker-myjd-api/actions/workflows/BuildImage.yml/dispatches --data '{"ref": "main"}'
curl -XPOST -u "${{ secrets.CR_USER }}:${{secrets.CR_PAT}}" -H "Accept: application/vnd.github.v3+json" -H "Content-Type: application/json" https://api.github.com/repos/rix1337/MyJD-API/actions/workflows/BuildImage.yml/dispatches --data '{"ref": "main", "inputs": {"version": "${{ steps.version.outputs.version }}"}"}'
23 changes: 23 additions & 0 deletions .github/workflows/UpdateOnBaseImageChange.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Regular base image update check
on:
schedule:
- cron: "0 */6 * * *"

env:
IMAGE_BASE: lsiobase/alpine.python3
IMAGE: rix1337/docker-myjd-api

jobs:
check-base-image:
runs-on: ubuntu-latest
steps:
- name: Docker Image Update Checker
id: baseupdatecheck
uses: lucacome/[email protected]
with:
base-image: ${{ env.IMAGE_BASE }}
image: ${{ env.IMAGE }}
- name: Trigger Docker Image build
run: |
curl -XPOST -u "${{ secrets.CR_USER }}:${{secrets.CR_PAT}}" -H "Accept: application/vnd.github.v3+json" -H "Content-Type: application/json" https://api.github.com/repos/rix1337/MyJD-API/actions/workflows/BuildImage.yml/dispatches --data '{"ref": "main"}'
if: steps.baseupdatecheck.outputs.needs-updating == 'true'
4 changes: 2 additions & 2 deletions MyJD.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from myjd_api import web
from myjd_api import run

if __name__ == '__main__':
web.main()
run.main()
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,32 @@ The official docker image is available at [Docker Hub](https://hub.docker.com/r/

`myjd_api`

# Parameters
## Parameters
* `--jd-user` Set your My JDownloader username
* `--jd-pass` Set your My JDownloader password
* `--jd-device` Set your My JDownloader device name
* `--port` _Optional:_ Set desired Port to serve the API
* `--username` _Optional:_ Set desired username for the API
* `--password` _Optional:_ Set desired username for the API

# Docker
```
docker run -d \
--name="MyJD-API" \
-p port:8080 \
-v /path/to/config/:/config:rw \
-e USER=USERNAME \
-e PASS=PASSWORD \
-e DEVICE=DEVICENAME \
rix1337/docker-myjd-api
```

## Optional Parameters
- `-e USER` (after first run, if unchanged)
- `-e PASS` (after first run, if unchanged)
- `-e DEVICE` (always, if only one device is present at MyJD-Account, otherwise after first run, if unchanged)


## Credits

* [mmarquezs](https://github.com/mmarquezs/)
30 changes: 30 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM ghcr.io/linuxserver/baseimage-alpine:3.18
MAINTAINER rix1337

# Define package name
ARG PACKAGE_NAME=myjd-api

# build tools
RUN apk add --no-cache build-base jq python3-dev py3-pip

# Optionally set desired version for the build
ARG VS="false"
RUN echo "VS: ${VS}"

# setup
RUN pip3 install --upgrade pip \
&& pip3 install wheel

# Install specified package version and clean up unneeded packages
RUN if [[ ${VS} == "false" ]] ; then echo "Grabbing latest version from pypi.org" && VERSION=$(curl -Ls https://pypi.org/pypi/${PACKAGE_NAME}/json | jq -r .info.version) ; else echo "Using version from workflow_dispatch input" && VERSION=$VS ; fi && \
echo $VERSION && \
pip3 install ${PACKAGE_NAME}=="$VERSION" --no-cache-dir && \
apk del build-base jq

# add local files
COPY root/ /

# volumes and ports
VOLUME /config
EXPOSE 8080
ENV PYTHONUNBUFFERED=1
13 changes: 13 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.3'
services:
docker-myjd-api:
container_name: MyJD-API
ports:
- 'port:8080'
volumes:
- '/path/to/config/:/config:rw'
environment:
- USER=USERNAME
- PASS=PASSWORD
- DEVICE=DEVICENAME
image: rix1337/docker-myjd-api:latest
1 change: 1 addition & 0 deletions docker/root/donate.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/sponsors/rix1337
3 changes: 3 additions & 0 deletions docker/root/etc/s6-overlay/s6-rc.d/init-adduser/branding
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
───────────────────────────────────────
MyJD-API
───────────────────────────────────────
3 changes: 3 additions & 0 deletions docker/root/etc/services.d/myjd_api/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/with-contenv bash

exec myjd_api --docker --jd-user=$USER --jd-pass=$PASS --jd-device=$DEVICE
Empty file added myjd_api/providers/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion myjd_api/common.py → myjd_api/providers/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import base64
import socket

from myjd_api import myjdapi
from myjd_api.providers import myjdapi


def check_ip():
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions myjd_api/files.py → myjd_api/providers/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import os
import sys

from myjd_api.config import Config
from myjd_api.myjd import get_device
from myjd_api.myjd import get_if_one_device
from myjd_api.providers.config import Config
from myjd_api.providers.myjd import get_device
from myjd_api.providers.myjd import get_if_one_device


def config():
Expand Down
Loading

0 comments on commit 7ec38bb

Please sign in to comment.