From 0322922c3980a1808ab7cc0b5f509e1ccb193236 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Tue, 20 Jun 2023 09:56:34 +0300 Subject: [PATCH 1/4] Create check.yml --- .github/workflows/check.yml | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/check.yml diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000000..665c1f9679 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,38 @@ +name: check +on: + workflow_dispatch: + pull_request: + types: [opened, synchronize, reopened, edited] +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 2 + - uses: tj-actions/changed-files@v35 + id: files + with: + files: streams/*.m3u + - uses: actions/setup-node@v3 + if: ${{ !env.ACT && steps.files.outputs.any_changed == 'true' }} + with: + node-version: 16 + cache: 'npm' + - name: download data from api + if: steps.files.outputs.any_changed == 'true' + run: | + mkdir -p scripts/data + curl -L -o scripts/data/blocklist.json https://iptv-org.github.io/api/blocklist.json + curl -L -o scripts/data/channels.json https://iptv-org.github.io/api/channels.json + - name: install dependencies + if: steps.files.outputs.any_changed == 'true' + run: npm install + - name: validate + if: steps.files.outputs.any_changed == 'true' + run: | + npm run playlist:lint -- ${{ steps.files.outputs.all_changed_files }} + npm run playlist:validate -- ${{ steps.files.outputs.all_changed_files }} \ No newline at end of file From d50ff6c2d743a7a791127bc610e36fbfab177da9 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Wed, 21 Jun 2023 13:05:34 +0300 Subject: [PATCH 2/4] Update db.js --- scripts/core/db.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/core/db.js b/scripts/core/db.js index 3cde1161da..6d016e8169 100644 --- a/scripts/core/db.js +++ b/scripts/core/db.js @@ -1,8 +1,11 @@ const nedb = require('nedb-promises') +const fs = require('fs-extra') const file = require('./file') const DB_DIR = process.env.DB_DIR || './scripts/tmp/database' +fs.ensureDirSync(DB_DIR) + class Database { constructor(filepath) { this.filepath = filepath From 7c2216e11d6c19c6239c35079c1bf45f5d4cc714 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Wed, 21 Jun 2023 13:15:44 +0300 Subject: [PATCH 3/4] Update package.json --- .github/workflows/update.yml | 53 ++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/update.yml diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml new file mode 100644 index 0000000000..a02ed59d80 --- /dev/null +++ b/.github/workflows/update.yml @@ -0,0 +1,53 @@ +name: update +on: + workflow_dispatch: + schedule: + - cron: '0 */6 * * *' +jobs: + main: + runs-on: ubuntu-latest + steps: + - uses: tibdex/github-app-token@v1 + if: ${{ !env.ACT }} + id: create-app-token + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.APP_PRIVATE_KEY }} + - uses: actions/checkout@v3 + if: ${{ env.ACT }} + - uses: actions/checkout@v3 + if: ${{ !env.ACT }} + with: + token: ${{ steps.create-app-token.outputs.token }} + - uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'npm' + - name: install dependencies + run: npm install + - name: load api data + run: npm run api:load + - name: validate playlists + run: | + npm run playlist:lint + npm run playlist:validate + - name: setup database + run: npm run db:create + - name: generate playlists + run: npm run playlist:generate + - name: generate streams.json + run: npm run api:generate + - name: update readme.md + run: npm run readme:update + - name: deploy to github pages + if: ${{ !env.ACT }} + run: GITHUB_TOKEN=${{ steps.create-app-token.outputs.token }} npm run deploy + - name: commit changes + if: ${{ !env.ACT }} + run: | + git config user.name "iptv-bot[bot]" + git config user.email "84861620+iptv-bot[bot]@users.noreply.github.com" + git add README.md + git commit -m "[Bot] Update README.md" -m "Committed by [iptv-bot](https://github.com/apps/iptv-bot) via [update](https://github.com/iptv-org/iptv/actions/runs/${{ github.run_id }}) workflow." --no-verify + git status + git push From d3f4943332dca4d098a3df60b117130248b7d516 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Wed, 21 Jun 2023 13:15:46 +0300 Subject: [PATCH 4/4] Update package.json --- package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.json b/package.json index 8326ba89c1..04d2ec1eea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,8 @@ { "name": "iptv", "scripts": { + "act:check": "act pull_request -W .github/workflows/check.yml", + "act:update": "act workflow_dispatch -W .github/workflows/update.yml", "api:load": "./scripts/commands/api/load.sh", "api:generate": "node scripts/commands/api/generate.js", "api:deploy": "npx gh-pages-clean && npx gh-pages -a -m \"Deploy to iptv-org/api\" -d .api -r https://$GITHUB_TOKEN@github.com/iptv-org/api.git -x",