Update .github/workflows

This commit is contained in:
freearhey
2025-10-22 02:29:24 +03:00
parent 605736d8c3
commit bc5677b4bb
3 changed files with 184 additions and 112 deletions

View File

@@ -1,53 +1,62 @@
name: check name: check
on: on:
workflow_dispatch: workflow_dispatch:
pull_request: pull_request:
types: [opened, synchronize, reopened, edited] types: [opened, synchronize, reopened, edited]
branches: branches:
- master - master
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true cancel-in-progress: true
jobs: permissions:
check: packages: read
runs-on: ubuntu-latest jobs:
steps: main:
- uses: actions/checkout@v4 runs-on: ubuntu-latest
with: steps:
fetch-depth: 2 - uses: actions/checkout@v4
- name: changed files - name: Get list of changed files
id: files id: files
run: | run: |
git fetch origin master:master git fetch origin master:master
JS_ANY_CHANGED=false 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' ' ') JS_ANY_CHANGED=false
if [ -n "${JS_ALL_CHANGED_FILES}" ]; then 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' ' ')
JS_ANY_CHANGED=true if [ -n "${JS_ALL_CHANGED_FILES}" ]; then
fi JS_ANY_CHANGED=true
echo "js_all_changed_files=$JS_ALL_CHANGED_FILES" >> "$GITHUB_OUTPUT" ANY_CHANGED=true
echo "js_any_changed=$JS_ANY_CHANGED" >> "$GITHUB_OUTPUT" fi
CHANNELS_ANY_CHANGED=false echo "js_all_changed_files=$JS_ALL_CHANGED_FILES" >> "$GITHUB_OUTPUT"
CHANNELS_ALL_CHANGED_FILES=$(git diff --name-only master -- sites/**/*.channels.xml | tr '\n' ' ') echo "js_any_changed=$JS_ANY_CHANGED" >> "$GITHUB_OUTPUT"
if [ -n "${CHANNELS_ALL_CHANGED_FILES}" ]; then CHANNELS_ANY_CHANGED=false
CHANNELS_ANY_CHANGED=true CHANNELS_ALL_CHANGED_FILES=$(git diff --name-only master -- sites/**/*.channels.xml | tr '\n' ' ')
fi if [ -n "${CHANNELS_ALL_CHANGED_FILES}" ]; then
echo "channels_all_changed_files=$CHANNELS_ALL_CHANGED_FILES" >> "$GITHUB_OUTPUT" CHANNELS_ANY_CHANGED=true
echo "channels_any_changed=$CHANNELS_ANY_CHANGED" >> "$GITHUB_OUTPUT" ANY_CHANGED=true
- uses: actions/setup-node@v4 fi
if: ${{ steps.files.outputs.js_any_changed == 'true' || steps.files.outputs.channels_any_changed == 'true' }} echo "channels_all_changed_files=$CHANNELS_ALL_CHANGED_FILES" >> "$GITHUB_OUTPUT"
with: echo "channels_any_changed=$CHANNELS_ANY_CHANGED" >> "$GITHUB_OUTPUT"
node-version: 22 echo "any_changed=$ANY_CHANGED" >> "$GITHUB_OUTPUT"
cache: 'npm' - uses: actions/setup-node@v4
- name: install dependencies if: steps.files.outputs.any_changed == 'true'
if: steps.files.outputs.js_any_changed == 'true' || steps.files.outputs.channels_any_changed == 'true' with:
run: SKIP_POSTINSTALL=1 npm install node-version: 22
- name: check changed js-files cache: 'npm'
if: steps.files.outputs.js_any_changed == 'true' - name: Setup .npmrc for GitHub Packages
run: | if: steps.files.outputs.any_changed == 'true'
npx eslint ${{ steps.files.outputs.js_all_changed_files }} run: |
- name: check changed *.channels.xml echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> .npmrc
if: steps.files.outputs.channels_any_changed == 'true' echo "@iptv-org:registry=https://npm.pkg.github.com/" >> .npmrc
run: | echo "always-auth=true" >> .npmrc
npm run channels:lint -- ${{ steps.files.outputs.channels_all_changed_files }} - name: Install dependencies
npm run postinstall 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 }} npm run channels:validate -- ${{ steps.files.outputs.channels_all_changed_files }}

64
.github/workflows/format.yml vendored Normal file
View File

@@ -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

View File

@@ -1,61 +1,60 @@
name: update name: update
on: on:
workflow_dispatch: workflow_dispatch:
schedule: schedule:
- cron: '0 0 * * *' - cron: '0 0 * * *'
jobs: jobs:
main: main:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: tibdex/github-app-token@v1.8.2 - uses: tibdex/github-app-token@v1.8.2
if: ${{ !env.ACT }} if: ${{ !env.ACT }}
id: create-app-token id: create-app-token
with: with:
app_id: ${{ secrets.APP_ID }} app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }} private_key: ${{ secrets.APP_PRIVATE_KEY }}
- uses: actions/checkout@v4 - uses: actions/checkout@v4
if: ${{ !env.ACT }} if: ${{ !env.ACT }}
with: with:
token: ${{ steps.create-app-token.outputs.token }} token: ${{ steps.create-app-token.outputs.token }}
- name: setup git - name: setup git
run: | run: |
git config user.name "iptv-bot[bot]" git config user.name "iptv-bot[bot]"
git config user.email "84861620+iptv-bot[bot]@users.noreply.github.com" git config user.email "84861620+iptv-bot[bot]@users.noreply.github.com"
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: 22 node-version: 22
cache: 'npm' cache: 'npm'
- name: install dependencies - name: install dependencies
run: npm install run: npm install
- name: check *.channels.xml - name: check *.channels.xml
run: | run: npm run channels:lint
npm run channels:lint - name: update sites.md
- name: update sites.md run: npm run sites:update
run: npm run sites:update - run: git status
- run: git status - name: commit changes to sites.md
- name: commit changes to sites.md if: ${{ !env.ACT && github.ref == 'refs/heads/master' }}
if: ${{ !env.ACT && github.ref == 'refs/heads/master' }} run: |
run: | SITE=SITES.md
SITE=SITES.md CHANGED=$(git diff ${SITE})
CHANGED=$(git diff ${SITE}) if [ -n "${CHANGED}" ]; then
if [ -n "${CHANGED}" ]; then git add ${SITE}
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 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
git push fi
fi - name: generate .api/guides.json
- name: generate .api/guides.json run: npm run api:generate
run: npm run api:generate - run: git status
- run: git status - name: move .api/guides.json to iptv-org/api
- name: move .api/guides.json to iptv-org/api uses: JamesIves/github-pages-deploy-action@4.1.1
uses: JamesIves/github-pages-deploy-action@4.1.1 if: ${{ !env.ACT && github.ref == 'refs/heads/master' }}
if: ${{ !env.ACT && github.ref == 'refs/heads/master' }} with:
with: repository-name: iptv-org/api
repository-name: iptv-org/api branch: gh-pages
branch: gh-pages folder: .api
folder: .api token: ${{ steps.create-app-token.outputs.token }}
token: ${{ steps.create-app-token.outputs.token }} git-config-name: iptv-bot[bot]
git-config-name: iptv-bot[bot] git-config-email: 84861620+iptv-bot[bot]@users.noreply.github.com
git-config-email: 84861620+iptv-bot[bot]@users.noreply.github.com commit-message: '[Bot] Deploy to iptv-org/api'
commit-message: '[Bot] Deploy to iptv-org/api'
clean: false clean: false