From c16627a3e7a35f71e3d7adc28667dbbef40eb6c9 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Sun, 17 Sep 2023 04:09:26 +0300 Subject: [PATCH] Create format.yml --- .github/workflows/format.yml | 67 ++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/format.yml diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 000000000..75a7eb93b --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,67 @@ +name: format +on: + pull_request: + types: + - closed +jobs: + main: + if: ${{ github.event.pull_request.merged == true }} + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 2 + - uses: getsentry/action-github-app-token@v2 + 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 }} + with: + fetch-depth: 2 + 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: tj-actions/changed-files@v35 + id: files + with: + files: streams/*.m3u + - name: download data from api + if: ${{ !env.ACT && steps.files.outputs.any_changed == 'true' }} + run: | + mkdir -p temp/data + curl -L -o temp/data/blocklist.json https://iptv-org.github.io/api/blocklist.json + curl -L -o temp/data/channels.json https://iptv-org.github.io/api/channels.json + - uses: actions/setup-node@v3 + if: ${{ !env.ACT && steps.files.outputs.any_changed == 'true' }} + with: + node-version: 18 + cache: 'npm' + - name: install dependencies + if: steps.files.outputs.any_changed == 'true' + run: npm install + - name: format internal playlists + if: steps.files.outputs.any_changed == 'true' + run: npm run playlist:format -- ${{ steps.files.outputs.all_changed_files }} + - name: check internal playlists + 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 }} + - run: git status + if: steps.files.outputs.any_changed == 'true' + - name: commit changes to /streams + if: steps.files.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.outputs.any_changed == 'true' }} + run: git push