Files
epg/.github/workflows/_update.yml
Aleksandr Statciuk 1afa72e87f Update _update.yml
2023-02-09 13:34:06 +03:00

92 lines
3.5 KiB
YAML

name: _update
on:
workflow_dispatch:
schedule:
- cron: '0 9 * * *'
jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: echo "BRANCH_NAME=$(date +'bot/auto-update-%s')" >> $GITHUB_OUTPUT
id: create-branch-name
- run: git config user.name 'iptv-bot[bot]'
- run: git config user.email '84861620+iptv-bot[bot]@users.noreply.github.com'
- run: git checkout -b ${{ steps.create-branch-name.outputs.BRANCH_NAME }}
- uses: tibdex/github-app-token@v1
if: ${{ !env.ACT }}
id: create-app-token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
- uses: actions/setup-node@v3
if: ${{ !env.ACT }}
with:
node-version: 16
cache: 'npm'
- run: npm install
- run: npm run api:load
- if: ${{ !env.ACT }}
run: GITHUB_TOKEN=${{ steps.create-app-token.outputs.token }} npm run db:load
- uses: actions/upload-artifact@v3
with:
name: database
path: scripts/database
- run: npm run guides:update
- uses: actions/upload-artifact@v3
with:
name: logs
path: scripts/logs
- run: npm run api:update
- run: npm run readme:update
- name: Commit Changes
if: ${{ !env.ACT }}
run: |
git add README.md
git commit --allow-empty -m "[Bot] Update README.md"
git status
- name: Push to origin
if: ${{ !env.ACT }}
run: |
git push -u origin ${{ steps.create-branch-name.outputs.BRANCH_NAME }}
- uses: JamesIves/github-pages-deploy-action@v4.4.1
if: ${{ !env.ACT && github.ref == 'refs/heads/master' }}
with:
branch: gh-pages
folder: .gh-pages
token: ${{ steps.create-app-token.outputs.token }}
git-config-name: iptv-bot[bot]
git-config-email: 84861620+iptv-bot[bot]@users.noreply.github.com
commit-message: '[Bot] Update guides'
single-commit: true
clean: true
- uses: JamesIves/github-pages-deploy-action@v4.4.1
if: ${{ !env.ACT && github.ref == 'refs/heads/master' }}
with:
repository-name: iptv-org/api
branch: gh-pages
folder: .api
token: ${{ steps.create-app-token.outputs.token }}
git-config-name: iptv-bot[bot]
git-config-email: 84861620+iptv-bot[bot]@users.noreply.github.com
commit-message: '[Bot] Deploy to iptv-org/api'
clean: false
- uses: repo-sync/pull-request@v2.9
if: ${{ !env.ACT && github.ref == 'refs/heads/master' }}
id: pull-request
with:
github_token: ${{ steps.create-app-token.outputs.token }}
source_branch: ${{ steps.create-branch-name.outputs.BRANCH_NAME }}
destination_branch: 'master'
pr_title: '[Bot] Daily update'
pr_body: |
This pull request is created via [update][1] workflow.
[1]: https://github.com/iptv-org/epg/actions/runs/${{ github.run_id }}
- uses: juliangruber/merge-pull-request-action@v1
if: ${{ !env.ACT && github.ref == 'refs/heads/master' && steps.pull-request.outputs.has_changed_files }}
with:
github-token: ${{ secrets.PAT }}
number: ${{ steps.pull-request.outputs.pr_number }}
method: squash