From bc5677b4bb9b9717426caf8f06b71c5cd5dba699 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Wed, 22 Oct 2025 02:29:24 +0300 Subject: [PATCH] Update .github/workflows --- .github/workflows/check.yml | 113 ++++++++++++++++++--------------- .github/workflows/format.yml | 64 +++++++++++++++++++ .github/workflows/update.yml | 119 +++++++++++++++++------------------ 3 files changed, 184 insertions(+), 112 deletions(-) create mode 100644 .github/workflows/format.yml diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 610e70d2..783a4fd0 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -1,53 +1,62 @@ -name: check -on: - workflow_dispatch: - pull_request: - types: [opened, synchronize, reopened, edited] - branches: - - master -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@v4 - with: - fetch-depth: 2 - - name: changed files - id: files - run: | - git fetch origin master:master - JS_ANY_CHANGED=false - JS_ALL_CHANGED_FILES=$(git diff --name-only master -- tests/**/*.js tests/**/*.ts scripts/**/*.js scripts/**/*.mts scripts/**/*.ts sites/**/*.js sites/**/*.ts | tr '\n' ' ') - if [ -n "${JS_ALL_CHANGED_FILES}" ]; then - JS_ANY_CHANGED=true - fi - echo "js_all_changed_files=$JS_ALL_CHANGED_FILES" >> "$GITHUB_OUTPUT" - echo "js_any_changed=$JS_ANY_CHANGED" >> "$GITHUB_OUTPUT" - CHANNELS_ANY_CHANGED=false - CHANNELS_ALL_CHANGED_FILES=$(git diff --name-only master -- sites/**/*.channels.xml | tr '\n' ' ') - if [ -n "${CHANNELS_ALL_CHANGED_FILES}" ]; then - CHANNELS_ANY_CHANGED=true - fi - echo "channels_all_changed_files=$CHANNELS_ALL_CHANGED_FILES" >> "$GITHUB_OUTPUT" - echo "channels_any_changed=$CHANNELS_ANY_CHANGED" >> "$GITHUB_OUTPUT" - - uses: actions/setup-node@v4 - if: ${{ steps.files.outputs.js_any_changed == 'true' || steps.files.outputs.channels_any_changed == 'true' }} - with: - node-version: 22 - cache: 'npm' - - name: install dependencies - if: steps.files.outputs.js_any_changed == 'true' || steps.files.outputs.channels_any_changed == 'true' - run: SKIP_POSTINSTALL=1 npm install - - name: check changed js-files - if: steps.files.outputs.js_any_changed == 'true' - run: | - npx eslint ${{ steps.files.outputs.js_all_changed_files }} - - name: check changed *.channels.xml - if: steps.files.outputs.channels_any_changed == 'true' - run: | - npm run channels:lint -- ${{ steps.files.outputs.channels_all_changed_files }} - npm run postinstall +name: check +on: + workflow_dispatch: + pull_request: + types: [opened, synchronize, reopened, edited] + branches: + - master +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true +permissions: + packages: read +jobs: + main: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Get list of changed files + id: files + run: | + git fetch origin master:master + ANY_CHANGED=false + JS_ANY_CHANGED=false + JS_ALL_CHANGED_FILES=$(git diff --name-only master -- tests/**/*.js tests/**/*.ts scripts/**/*.js scripts/**/*.mts scripts/**/*.ts sites/**/*.js sites/**/*.ts | tr '\n' ' ') + if [ -n "${JS_ALL_CHANGED_FILES}" ]; then + JS_ANY_CHANGED=true + ANY_CHANGED=true + fi + echo "js_all_changed_files=$JS_ALL_CHANGED_FILES" >> "$GITHUB_OUTPUT" + echo "js_any_changed=$JS_ANY_CHANGED" >> "$GITHUB_OUTPUT" + CHANNELS_ANY_CHANGED=false + CHANNELS_ALL_CHANGED_FILES=$(git diff --name-only master -- sites/**/*.channels.xml | tr '\n' ' ') + if [ -n "${CHANNELS_ALL_CHANGED_FILES}" ]; then + CHANNELS_ANY_CHANGED=true + ANY_CHANGED=true + fi + echo "channels_all_changed_files=$CHANNELS_ALL_CHANGED_FILES" >> "$GITHUB_OUTPUT" + echo "channels_any_changed=$CHANNELS_ANY_CHANGED" >> "$GITHUB_OUTPUT" + echo "any_changed=$ANY_CHANGED" >> "$GITHUB_OUTPUT" + - uses: actions/setup-node@v4 + if: steps.files.outputs.any_changed == 'true' + with: + node-version: 22 + cache: 'npm' + - name: Setup .npmrc for GitHub Packages + if: steps.files.outputs.any_changed == 'true' + run: | + echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> .npmrc + echo "@iptv-org:registry=https://npm.pkg.github.com/" >> .npmrc + echo "always-auth=true" >> .npmrc + - name: Install dependencies + if: steps.files.outputs.any_changed == 'true' + run: SKIP_POSTINSTALL=1 npm install + - name: Check changed js-files + if: steps.files.outputs.js_any_changed == 'true' + run: npx eslint ${{ steps.files.outputs.js_all_changed_files }} + - name: Check changed *.channels.xml files + if: steps.files.outputs.channels_any_changed == 'true' + run: | + npm run postinstall + npm run channels:lint -- ${{ steps.files.outputs.channels_all_changed_files }} npm run channels:validate -- ${{ steps.files.outputs.channels_all_changed_files }} \ No newline at end of file diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 00000000..279ca906 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,64 @@ +name: format +on: + workflow_dispatch: + # schedule: + # - cron: "0 12 * * *" +permissions: + packages: read +jobs: + main: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: tibdex/github-app-token@v1.8.2 + if: ${{ !env.ACT }} + id: create-app-token + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.APP_PRIVATE_KEY }} + - uses: actions/checkout@v4 + if: ${{ !env.ACT }} + with: + token: ${{ steps.create-app-token.outputs.token }} + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: 'npm' + - name: Setup .npmrc for GitHub Packages + run: | + echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> .npmrc + echo "@iptv-org:registry=https://npm.pkg.github.com/" >> .npmrc + echo "always-auth=true" >> .npmrc + - name: Install dependencies + run: npm install + - name: Format *.channels.xml files + run: npm run channels:format + - name: Get list of changed *.channels.xml files + id: files + run: | + git fetch origin master:master + CHANNELS_ANY_CHANGED=false + CHANNELS_ALL_CHANGED_FILES=$(git diff --name-only master -- sites/**/*.channels.xml | tr '\n' ' ') + if [ -n "${CHANNELS_ALL_CHANGED_FILES}" ]; then + CHANNELS_ANY_CHANGED=true + fi + echo "channels_all_changed_files=$CHANNELS_ALL_CHANGED_FILES" >> "$GITHUB_OUTPUT" + echo "channels_any_changed=$CHANNELS_ANY_CHANGED" >> "$GITHUB_OUTPUT" + - name: Check changed *.channels.xml files + if: steps.files.outputs.channels_any_changed == 'true' + run: | + npm run channels:lint -- ${{ steps.files.outputs.channels_all_changed_files }} + npm run channels:validate -- ${{ steps.files.outputs.channels_all_changed_files }} + - name: Setup git + run: | + git config user.name "iptv-bot[bot]" + git config user.email "84861620+iptv-bot[bot]@users.noreply.github.com" + - name: Commit changed *.channels.xml files + if: steps.files_after.outputs.channels_any_changed == 'true' + run: | + git add streams + git status + git commit -m "[Bot] Format *.channels.xml files" -m "Committed by [iptv-bot](https://github.com/apps/iptv-bot) via [format](https://github.com/iptv-org/epg/actions/runs/${{ github.run_id }}) workflow." --no-verify + - name: Push all changes to the repository + if: ${{ !env.ACT && github.ref == 'refs/heads/master' && steps.files_after.outputs.channels_any_changed == 'true' }} + run: git push \ No newline at end of file diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 9975722d..4015aa19 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -1,61 +1,60 @@ -name: update -on: - workflow_dispatch: - schedule: - - cron: '0 0 * * *' -jobs: - main: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: tibdex/github-app-token@v1.8.2 - if: ${{ !env.ACT }} - id: create-app-token - with: - app_id: ${{ secrets.APP_ID }} - private_key: ${{ secrets.APP_PRIVATE_KEY }} - - uses: actions/checkout@v4 - if: ${{ !env.ACT }} - with: - token: ${{ steps.create-app-token.outputs.token }} - - name: setup git - run: | - git config user.name "iptv-bot[bot]" - git config user.email "84861620+iptv-bot[bot]@users.noreply.github.com" - - uses: actions/setup-node@v4 - with: - node-version: 22 - cache: 'npm' - - name: install dependencies - run: npm install - - name: check *.channels.xml - run: | - npm run channels:lint - - name: update sites.md - run: npm run sites:update - - run: git status - - name: commit changes to sites.md - if: ${{ !env.ACT && github.ref == 'refs/heads/master' }} - run: | - SITE=SITES.md - CHANGED=$(git diff ${SITE}) - if [ -n "${CHANGED}" ]; then - git add ${SITE} - git commit -m "[Bot] Update ${SITE}" -m "Committed by [iptv-bot](https://github.com/apps/iptv-bot) via [update](https://github.com/iptv-org/epg/actions/runs/${{ github.run_id }}) workflow." --no-verify - git push - fi - - name: generate .api/guides.json - run: npm run api:generate - - run: git status - - name: move .api/guides.json to iptv-org/api - uses: JamesIves/github-pages-deploy-action@4.1.1 - if: ${{ !env.ACT && github.ref == 'refs/heads/master' }} - with: - repository-name: iptv-org/api - branch: gh-pages - folder: .api - token: ${{ steps.create-app-token.outputs.token }} - git-config-name: iptv-bot[bot] - git-config-email: 84861620+iptv-bot[bot]@users.noreply.github.com - commit-message: '[Bot] Deploy to iptv-org/api' +name: update +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * *' +jobs: + main: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: tibdex/github-app-token@v1.8.2 + if: ${{ !env.ACT }} + id: create-app-token + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.APP_PRIVATE_KEY }} + - uses: actions/checkout@v4 + if: ${{ !env.ACT }} + with: + token: ${{ steps.create-app-token.outputs.token }} + - name: setup git + run: | + git config user.name "iptv-bot[bot]" + git config user.email "84861620+iptv-bot[bot]@users.noreply.github.com" + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: 'npm' + - name: install dependencies + run: npm install + - name: check *.channels.xml + run: npm run channels:lint + - name: update sites.md + run: npm run sites:update + - run: git status + - name: commit changes to sites.md + if: ${{ !env.ACT && github.ref == 'refs/heads/master' }} + run: | + SITE=SITES.md + CHANGED=$(git diff ${SITE}) + if [ -n "${CHANGED}" ]; then + git add ${SITE} + git commit -m "[Bot] Update ${SITE}" -m "Committed by [iptv-bot](https://github.com/apps/iptv-bot) via [update](https://github.com/iptv-org/epg/actions/runs/${{ github.run_id }}) workflow." --no-verify + git push + fi + - name: generate .api/guides.json + run: npm run api:generate + - run: git status + - name: move .api/guides.json to iptv-org/api + uses: JamesIves/github-pages-deploy-action@4.1.1 + if: ${{ !env.ACT && github.ref == 'refs/heads/master' }} + with: + repository-name: iptv-org/api + branch: gh-pages + folder: .api + token: ${{ steps.create-app-token.outputs.token }} + git-config-name: iptv-bot[bot] + git-config-email: 84861620+iptv-bot[bot]@users.noreply.github.com + commit-message: '[Bot] Deploy to iptv-org/api' clean: false \ No newline at end of file