iptv/.github/workflows/auto-update.yml

283 lines
9.3 KiB
YAML
Raw Normal View History

2021-02-08 12:05:46 +01:00
name: auto-update
2021-02-08 11:53:24 +01:00
on:
workflow_dispatch:
schedule:
2021-09-05 23:54:12 +02:00
- cron: '0 0,12 * * *'
2021-02-08 11:53:24 +01:00
jobs:
2021-08-02 03:13:25 +02:00
create-branch:
runs-on: ubuntu-latest
2021-11-26 23:47:38 +01:00
outputs:
branch_name: ${{ steps.set-branch-name.outputs.branch_name }}
2021-08-02 03:13:25 +02:00
steps:
- name: Checkout
uses: actions/checkout@v2
2021-08-02 03:18:18 +02:00
with:
2021-08-03 06:30:37 +02:00
ref: ${{ github.ref }}
2021-11-26 23:31:02 +01:00
- name: Set Branch Name
id: set-branch-name
2021-11-27 00:04:36 +01:00
run: echo "::set-output name=branch_name::$(date +'bot/auto-update-%Y%m%d%H%M00')"
2021-08-03 06:20:34 +02:00
- name: Create Branch
uses: peterjgrainger/action-create-branch@v2.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
2021-11-26 23:31:02 +01:00
branch: ${{ steps.set-branch-name.outputs.branch_name }}
2021-09-08 23:54:29 +02:00
create-matrix:
2021-07-13 18:18:04 +02:00
runs-on: ubuntu-latest
2021-08-03 07:12:42 +02:00
needs: create-branch
2021-09-08 23:54:29 +02:00
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
2021-09-09 00:27:05 +02:00
- name: Checkout
uses: actions/checkout@v2
with:
2021-11-27 00:04:36 +01:00
ref: ${{ needs.create-branch.outputs.branch_name }}
2021-11-26 20:00:49 +01:00
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14'
cache: 'npm'
2021-09-09 00:27:05 +02:00
- name: Install Dependencies
run: npm install
2021-09-09 00:22:26 +02:00
- name: Create Matrix
id: set-matrix
run: node scripts/create-matrix.js
2021-09-08 23:54:29 +02:00
format:
runs-on: ubuntu-latest
2021-11-27 00:04:36 +01:00
needs: [create-matrix, create-branch]
2021-08-03 07:33:07 +02:00
continue-on-error: true
strategy:
fail-fast: false
2021-09-08 23:54:29 +02:00
matrix: ${{fromJSON(needs.create-matrix.outputs.matrix)}}
2021-08-03 07:33:07 +02:00
steps:
- name: Checkout
uses: actions/checkout@v2
with:
2021-11-27 00:04:36 +01:00
ref: ${{ needs.create-branch.outputs.branch_name }}
- name: Setup FFmpeg
uses: FedericoCarboni/setup-ffmpeg@v1
2021-11-26 20:00:49 +01:00
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14'
cache: 'npm'
2021-08-03 07:33:07 +02:00
- name: Install Dependencies
run: npm install
- name: Format Playlists
2021-11-27 00:28:05 +01:00
run: node scripts/format.js --country=${{ matrix.country }} --debug
2021-08-03 07:33:07 +02:00
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: channels
path: channels/${{ matrix.country }}.m3u
commit-changes:
runs-on: ubuntu-latest
2021-11-27 00:04:36 +01:00
needs: [format, create-branch]
2021-08-03 07:33:07 +02:00
steps:
- name: Checkout
uses: actions/checkout@v2
with:
2021-11-27 00:04:36 +01:00
ref: ${{ needs.create-branch.outputs.branch_name }}
2021-08-03 07:33:07 +02:00
- name: Download Artifacts
uses: actions/download-artifact@v2
with:
name: channels
2021-08-04 04:01:33 +02:00
path: channels
2021-08-03 07:33:07 +02:00
- name: Commit Changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: '[Bot] Format playlists'
2021-08-10 02:34:13 +02:00
commit_user_name: iptv-bot
commit_user_email: 84861620+iptv-bot[bot]@users.noreply.github.com
commit_author: 'iptv-bot[bot] <84861620+iptv-bot[bot]@users.noreply.github.com>'
2021-11-27 00:04:36 +01:00
branch: ${{ needs.create-branch.outputs.branch_name }}
2021-08-10 02:34:13 +02:00
file_pattern: channels/*
remove-duplicates:
2021-08-10 02:34:13 +02:00
runs-on: ubuntu-latest
2021-11-27 00:04:36 +01:00
needs: [commit-changes, create-branch]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
2021-11-27 00:04:36 +01:00
ref: ${{ needs.create-branch.outputs.branch_name }}
2021-11-26 20:00:49 +01:00
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14'
cache: 'npm'
- name: Install Dependencies
run: npm install
- name: Remove Duplicates
run: node scripts/remove-duplicates.js
- name: Commit Changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: '[Bot] Remove duplicates'
commit_user_name: iptv-bot
commit_user_email: 84861620+iptv-bot[bot]@users.noreply.github.com
commit_author: 'iptv-bot[bot] <84861620+iptv-bot[bot]@users.noreply.github.com>'
2021-11-27 00:04:36 +01:00
branch: ${{ needs.create-branch.outputs.branch_name }}
file_pattern: channels/*
sort:
runs-on: ubuntu-latest
2021-11-27 00:04:36 +01:00
needs: [remove-duplicates, create-branch]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
2021-11-27 00:04:36 +01:00
ref: ${{ needs.create-branch.outputs.branch_name }}
2021-11-26 20:00:49 +01:00
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14'
cache: 'npm'
- name: Install Dependencies
run: npm install
- name: Sort Channels
run: node scripts/sort.js
- name: Commit Changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: '[Bot] Sort channels'
commit_user_name: iptv-bot
commit_user_email: 84861620+iptv-bot[bot]@users.noreply.github.com
commit_author: 'iptv-bot[bot] <84861620+iptv-bot[bot]@users.noreply.github.com>'
2021-11-27 00:04:36 +01:00
branch: ${{ needs.create-branch.outputs.branch_name }}
file_pattern: channels/*
filter:
runs-on: ubuntu-latest
2021-11-27 00:04:36 +01:00
needs: [sort, create-branch]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
2021-11-27 00:04:36 +01:00
ref: ${{ needs.create-branch.outputs.branch_name }}
2021-11-26 20:00:49 +01:00
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14'
cache: 'npm'
- name: Install Dependencies
run: npm install
- name: Filter Playlists
run: node scripts/filter.js
- name: Commit Changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: '[Bot] Filter channels'
commit_user_name: iptv-bot
commit_user_email: 84861620+iptv-bot[bot]@users.noreply.github.com
commit_author: 'iptv-bot[bot] <84861620+iptv-bot[bot]@users.noreply.github.com>'
2021-11-27 00:04:36 +01:00
branch: ${{ needs.create-branch.outputs.branch_name }}
file_pattern: channels/*
generate:
runs-on: ubuntu-latest
2021-11-27 00:04:36 +01:00
needs: [filter, create-branch]
2021-08-03 07:33:07 +02:00
steps:
- name: Checkout
uses: actions/checkout@v2
with:
2021-11-27 00:04:36 +01:00
ref: ${{ needs.create-branch.outputs.branch_name }}
2021-11-26 20:00:49 +01:00
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14'
cache: 'npm'
2021-08-03 07:33:07 +02:00
- name: Install Dependencies
run: npm install
- name: Generate Playlists
run: node scripts/generate.js
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: gh-pages
path: .gh-pages/
deploy:
runs-on: ubuntu-latest
2021-11-27 00:04:36 +01:00
needs: [generate, create-branch]
2021-08-03 07:33:07 +02:00
steps:
- name: Checkout
uses: actions/checkout@v2
with:
2021-11-27 00:04:36 +01:00
ref: ${{ needs.create-branch.outputs.branch_name }}
2021-08-03 07:33:07 +02:00
- name: Download Artifacts
uses: actions/download-artifact@v2
with:
name: gh-pages
2021-08-04 04:00:49 +02:00
path: .gh-pages
2021-08-03 07:33:07 +02:00
- name: Generate Token
uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Deploy to GitHub Pages
2021-11-26 20:00:49 +01:00
if: ${{ github.ref == 'refs/heads/master' }}
2021-08-03 07:33:07 +02:00
uses: JamesIves/github-pages-deploy-action@4.1.1
with:
branch: gh-pages
2021-08-04 04:00:49 +02:00
folder: .gh-pages
2021-08-03 07:33:07 +02:00
token: ${{ steps.generate-token.outputs.token }}
git-config-name: iptv-bot
git-config-email: 84861620+iptv-bot[bot]@users.noreply.github.com
commit-message: '[Bot] Deploy to GitHub Pages'
update-readme:
runs-on: ubuntu-latest
2021-11-27 00:04:36 +01:00
needs: [generate, create-branch]
2021-08-03 07:33:07 +02:00
steps:
- name: Checkout
uses: actions/checkout@v2
with:
2021-11-27 00:04:36 +01:00
ref: ${{ needs.create-branch.outputs.branch_name }}
2021-11-26 20:00:49 +01:00
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14'
cache: 'npm'
2021-08-03 07:33:07 +02:00
- name: Install Dependencies
run: npm install
- name: Update README.md
run: node scripts/update-readme.js
- name: Commit Changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: '[Bot] Update README.md'
commit_user_name: iptv-bot
commit_user_email: 84861620+iptv-bot[bot]@users.noreply.github.com
commit_author: 'iptv-bot[bot] <84861620+iptv-bot[bot]@users.noreply.github.com>'
2021-11-27 00:04:36 +01:00
branch: ${{ needs.create-branch.outputs.branch_name }}
2021-08-03 07:33:07 +02:00
file_pattern: README.md
pull-request:
if: ${{ github.ref == 'refs/heads/master' }}
2021-11-27 00:04:36 +01:00
needs: [update-readme, create-branch]
2021-05-26 15:10:28 +02:00
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
2021-08-03 04:34:41 +02:00
with:
2021-11-27 00:04:36 +01:00
ref: ${{ needs.create-branch.outputs.branch_name }}
2021-05-26 17:23:27 +02:00
- name: Generate Token
uses: tibdex/github-app-token@v1
2021-08-03 02:23:24 +02:00
id: generate-token
2021-05-26 17:23:27 +02:00
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
2021-05-26 15:10:28 +02:00
- name: Create Pull Request
2021-05-26 16:16:58 +02:00
id: pr
2021-08-03 07:26:55 +02:00
uses: repo-sync/pull-request@v2
2021-05-26 15:10:28 +02:00
with:
2021-11-27 00:04:36 +01:00
source_branch: ${{ needs.create-branch.outputs.branch_name }}
2021-08-03 07:26:55 +02:00
destination_branch: 'master'
pr_title: '[Bot] Update playlists'
pr_body: |
2021-08-03 03:30:15 +02:00
This pull request is created by [auto-update][1] workflow.
2021-08-02 04:43:08 +02:00
2021-08-03 03:30:15 +02:00
[1]: https://github.com/iptv-org/iptv/actions/runs/${{ github.run_id }}
2021-08-03 07:26:55 +02:00
github_token: ${{ steps.generate-token.outputs.token }}
2021-10-01 17:37:40 +02:00
- name: Merge Pull Request
uses: juliangruber/merge-pull-request-action@v1
2021-08-03 07:33:07 +02:00
with:
github-token: ${{ secrets.PAT }}
2021-08-03 07:36:25 +02:00
number: ${{ steps.pr.outputs.pr_number }}
2021-10-01 17:37:40 +02:00
method: squash