diff options
-rw-r--r-- | .github/workflows/dockerbuild.yml | 9 | ||||
-rw-r--r-- | .github/workflows/documentation.yml | 27 | ||||
-rw-r--r-- | .github/workflows/lint.yml | 1 | ||||
-rw-r--r-- | .github/workflows/prhtmlgenerator.yml | 126 | ||||
-rw-r--r-- | .github/workflows/tests.yml | 1 | ||||
-rw-r--r-- | bridges/LeagueOfLegendsPatchNotesBridge.php | 107 |
6 files changed, 108 insertions, 163 deletions
diff --git a/.github/workflows/dockerbuild.yml b/.github/workflows/dockerbuild.yml index 39645558..f65a72c2 100644 --- a/.github/workflows/dockerbuild.yml +++ b/.github/workflows/dockerbuild.yml @@ -8,8 +8,7 @@ on: - '20*' env: - DOCKERHUB_SLUG: rssbridge/rss-bridge - GHCR_SLUG: ghcr.io/rss-bridge/rss-bridge + GHCR_SLUG: ghcr.io/ansg191/rss-bridge jobs: bake: @@ -38,12 +37,6 @@ jobs: name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Login to DockerHub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml deleted file mode 100644 index e0201022..00000000 --- a/.github/workflows/documentation.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Documentation - -on: - push: - paths: - - 'docs/**' - -jobs: - documentation: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.0 - - name: Install dependencies - run: composer global require daux/daux.io - - name: Generate documentation - run: daux generate - - name: Deploy same repository 🚀 - uses: JamesIves/github-pages-deploy-action@v4 - with: - folder: "static" - branch: gh-pages diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 206b53de..d589db66 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,7 +2,6 @@ name: Lint on: push: - branches: [ master ] pull_request: branches: [ master ] diff --git a/.github/workflows/prhtmlgenerator.yml b/.github/workflows/prhtmlgenerator.yml deleted file mode 100644 index 163d51e3..00000000 --- a/.github/workflows/prhtmlgenerator.yml +++ /dev/null @@ -1,126 +0,0 @@ -name: 'PR Testing' - -on: - pull_request_target: - branches: [ master ] - -jobs: - check-bridges: - name: Check if bridges were changed - runs-on: ubuntu-latest - outputs: - BRIDGES: ${{ steps.check1.outputs.BRIDGES }} - steps: - - name: Check number of bridges - id: check1 - run: | - PR=${{github.event.number}}; - wget https://patch-diff.githubusercontent.com/raw/$GITHUB_REPOSITORY/pull/$PR.patch; - bridgeamount=$(cat $PR.patch | grep "\bbridges/[A-Za-z0-9]*Bridge\.php\b" | sed "s=.*\bbridges/\([A-Za-z0-9]*\)Bridge\.php\b.*=\1=g" | sort | uniq | wc -l); - echo "BRIDGES=$bridgeamount" >> "$GITHUB_OUTPUT" - test-pr: - name: Generate HTML - runs-on: ubuntu-latest - needs: check-bridges - if: needs.check-bridges.outputs.BRIDGES > 0 - env: - PYTHONUNBUFFERED: 1 - # Needs additional permissions https://github.com/actions/first-interaction/issues/10#issuecomment-1041402989 - steps: - - name: Check out self - uses: actions/checkout@v4 - with: - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - - name: Check out rss-bridge - run: | - PR=${{github.event.number}}; - wget -O requirements.txt https://raw.githubusercontent.com/$GITHUB_REPOSITORY/${{ github.event.pull_request.base.ref }}/.github/prtester-requirements.txt; - wget https://raw.githubusercontent.com/$GITHUB_REPOSITORY/${{ github.event.pull_request.base.ref }}/.github/prtester.py; - wget https://patch-diff.githubusercontent.com/raw/$GITHUB_REPOSITORY/pull/$PR.patch; - touch DEBUG; - cat $PR.patch | grep "\bbridges/[A-Za-z0-9]*Bridge\.php\b" | sed "s=.*\bbridges/\([A-Za-z0-9]*\)Bridge\.php\b.*=\1=g" | sort | uniq > whitelist.txt - - name: Start Docker - Current - run: | - docker run -d -v $GITHUB_WORKSPACE/whitelist.txt:/app/whitelist.txt -v $GITHUB_WORKSPACE/DEBUG:/app/DEBUG -p 3000:80 ghcr.io/rss-bridge/rss-bridge:latest - - name: Start Docker - PR - run: | - docker build -t prbuild .; - docker run -d -v $GITHUB_WORKSPACE/whitelist.txt:/app/whitelist.txt -v $GITHUB_WORKSPACE/DEBUG:/app/DEBUG -p 3001:80 prbuild - - name: Setup python - uses: actions/setup-python@v5 - with: - python-version: '3.13' - cache: 'pip' - - name: Install requirements - run: | - cd $GITHUB_WORKSPACE - pip install -r requirements.txt - - name: Run bridge tests - id: testrun - run: | - mkdir results; - python prtester.py; - body="$(cat comment.txt)"; - body="${body//'%'/'%25'}"; - body="${body//$'\n'/'%0A'}"; - body="${body//$'\r'/'%0D'}"; - echo "bodylength=${#body}" >> $GITHUB_OUTPUT - env: - PR: ${{ github.event.number }} - - name: Upload generated tests - uses: actions/upload-artifact@v4 - id: upload-generated-tests - with: - name: tests - path: '*.html' - - name: Find Comment - if: ${{ steps.testrun.outputs.bodylength > 130 }} - uses: peter-evans/find-comment@v3 - id: fc - with: - issue-number: ${{ github.event.pull_request.number }} - comment-author: 'github-actions[bot]' - body-includes: Pull request artifacts - - name: Create or update comment - if: ${{ steps.testrun.outputs.bodylength > 130 }} - uses: peter-evans/create-or-update-comment@v4 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - body-file: comment.txt - edit-mode: replace - upload_tests: - name: Upload tests - runs-on: ubuntu-latest - needs: test-pr - steps: - - uses: actions/checkout@v4 - with: - repository: 'RSS-Bridge/rss-bridge-tests' - ref: 'main' - token: ${{ secrets.RSSTESTER_ACTION }} - - - name: Setup git config - run: | - git config --global user.name "GitHub Actions" - git config --global user.email "<>" - - - name: Download tests - uses: actions/download-artifact@v4 - with: - name: tests - - - name: Move tests - run: | - cd prs - mkdir -p ${{github.event.number}} - cd ${{github.event.number}} - mv -f $GITHUB_WORKSPACE/*.html . - - - name: Commit and push generated tests - run: | - export COMMIT_MESSAGE="Added tests for PR ${{github.event.number}}" - git add . - git commit -m "$COMMIT_MESSAGE" - git push diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 93f07b0f..7bad3fb2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,7 +2,6 @@ name: Tests on: push: - branches: [ master ] pull_request: branches: [ master ] diff --git a/bridges/LeagueOfLegendsPatchNotesBridge.php b/bridges/LeagueOfLegendsPatchNotesBridge.php new file mode 100644 index 00000000..4b6fbb29 --- /dev/null +++ b/bridges/LeagueOfLegendsPatchNotesBridge.php @@ -0,0 +1,107 @@ +<?php + +class LeagueOfLegendsPatchNotesBridge extends BridgeAbstract +{ + const NAME = 'League of Legends Patch Notes'; + const URI = 'https://www.leagueoflegends.com/'; + const DESCRIPTION = 'League of Legends Patch Notes newsfeed'; + const MAINTAINER = 'ansg191'; + const PARAMETERS = [ + '' => [ + 'locale' => [ + 'name' => 'Language', + 'type' => 'list', + 'values' => [ + 'العربية' => 'ar-ae', + 'čeština' => 'cs-cz', + 'Deutsch' => 'de-de', + 'Ελληνικά' => 'el-gr', + 'English (AU)' => 'en-au', + 'English (EU)' => 'en-gb', + 'English (US)' => 'en-us', + 'Español (EU)' => 'es-es', + 'Español (AL)' => 'es-mx', + 'Français' => 'fr-fr', + 'magyar' => 'hu-hu', + 'Italiano' => 'it-it', + '日本語' => 'ja-jp', + '한국어' => 'ko-kr', + 'Polski' => 'pl-pl', + 'română' => 'ro-ro', + 'Português (AL)' => 'pt-br', + 'Русский' => 'ru-ru', + 'ภาษาไทย' => 'th-th', + 'Türkçe' => 'tr-tr', +// '简体中文' => 'zh-cn', + '繁體中文' => 'zh-tw' + ], + 'defaultValue' => 'en-us', + 'title' => 'Select your language' + ] + ] + ]; + const CACHE_TIMEOUT = 3600; + + public function getIcon() + { + return <<<icon +https://cmsassets.rgpub.io/sanity/images/dsfx7636/content_organization_live/c0ff1c73fab6ddc82472ff5c79c9bd5a0032c616-110x70.svg +icon; + } + + public function collectData() + { + $url = sprintf('https://www.leagueoflegends.com/%s/news/tags/patch-notes/', $this->getInput('locale')); + $dom = getSimpleHTMLDOMCached($url); + $dom = $dom->find('section[id=news]', 0); + if (!$dom) { + throw new \Exception(sprintf('Unable to find css selector on `%s`', $url)); + } + $dom = defaultLinkTo($dom, $this->getURI()); + + foreach ($dom->find('a[data-testid="articlefeaturedcard-component"]') as $article) { + $title = $article->find('div[data-testid="card-title"]', 0)->plaintext; + $info = $this->getArticle($article->href); + $this->items[] = [ + 'title' => $title, + 'uri' => $article->href, + 'author' => $info->author, + 'content' => $info->content, + 'timestamp' => strtotime($article->find('time', 0)->datetime), + 'enclosures' => [$info->banner] + ]; + } + } + + /** + * Loads the patch notes page to get author, content, and banner image. + * + * @param $url string + * @return object + */ + private function getArticle($url) + { + $dom = getSimpleHTMLDOMCached($url); + $dom = defaultLinkTo($dom, $this->getURI()); + + $author = ''; + $content = $dom->find('section[data-testid="RichTextPatchNotesBlade"]', 0); + $banner = ''; + + $authorEl = $dom->find('div[class="authors"] > span', 0); + if ($authorEl) { + $author = $authorEl->plaintext; + } + + $bannerEl = $dom->find('meta[property="og:image"]', 0); + if ($bannerEl) { + $banner = $bannerEl->content; + } + + return (object)[ + 'author' => $author, + 'content' => $content, + 'banner' => $banner, + ]; + } +} |