format #500
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: format | |
| on: | |
| workflow_dispatch: | |
| # schedule: | |
| # - cron: "0 12 * * *" | |
| jobs: | |
| main: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - 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@v6 | |
| if: ${{ !env.ACT }} | |
| with: | |
| token: ${{ steps.create-app-token.outputs.token }} | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Format internal playlists | |
| run: npm run playlist:format | |
| - name: Check internal playlists | |
| run: | | |
| npm run playlist:lint | |
| npm run playlist:validate | |
| - name: Get list of changed files | |
| id: files_after | |
| run: | | |
| ANY_CHANGED=false | |
| ALL_CHANGED_FILES=$(git diff --diff-filter=ACMRT --name-only master -- streams/ | tr '\n' ' ') | |
| if [ -n "${ALL_CHANGED_FILES}" ]; then | |
| ANY_CHANGED=true | |
| fi | |
| echo "all_changed_files=$ALL_CHANGED_FILES" >> "$GITHUB_OUTPUT" | |
| echo "any_changed=$ANY_CHANGED" >> "$GITHUB_OUTPUT" | |
| - 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 changes to /streams | |
| if: steps.files_after.outputs.any_changed == 'true' | |
| run: | | |
| git add streams | |
| git status | |
| git commit -m "[Bot] Format /streams" -m "Committed by [iptv-bot](https://github.com/apps/iptv-bot) via [format](https://github.com/iptv-org/iptv/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.any_changed == 'true' }} | |
| run: git push |