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

@@ -8,21 +8,23 @@ on:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
packages: read
jobs:
check:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: changed files
- 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"
@@ -30,24 +32,31 @@ jobs:
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.js_any_changed == 'true' || steps.files.outputs.channels_any_changed == 'true' }}
if: steps.files.outputs.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'
- name: Setup .npmrc for GitHub Packages
if: steps.files.outputs.any_changed == 'true'
run: |
npx eslint ${{ steps.files.outputs.js_all_changed_files }}
- name: check changed *.channels.xml
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 channels:lint -- ${{ steps.files.outputs.channels_all_changed_files }}
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 }}

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

@@ -29,8 +29,7 @@ jobs:
- name: install dependencies
run: npm install
- name: check *.channels.xml
run: |
npm run channels:lint
run: npm run channels:lint
- name: update sites.md
run: npm run sites:update
- run: git status