Skip to content

EPG

EPG #175

Workflow file for this run

name: EPG
on:
schedule:
- cron: 0 * * * *
- cron: 30 4,10,15,16 * * *
push:
branches:
- main
- master
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- url: https://epg.112114.xyz/pp.xml.gz
branch: main
- url: http://epg.51zmt.top:8000/e.xml
branch: master
steps:
- uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}
- name: download xml-file
working-directory: xml
run: |
url="${{ matrix.url }}"
if [[ "$url" == *".gz" ]]; then
echo "url以gz结尾"
wget $url -O e.xml.gz
gzip -df e.xml.gz
else
echo "url不以gz结尾"
wget $url -O e.xml
fi
- name: check md5
run: |
md5=$(md5sum ./xml/e.xml | awk '{print $1}')
if ! grep -q "$md5" ./md5.txt; then
echo "isDiff=$md5" >> $GITHUB_ENV
fi
- name: xml to json
if: ${{ env.isDiff }}
run: |
pip3 install -r requirements.txt
python3 xml2json.py
- name: move file
if: ${{ env.isDiff }}
run: |
now_date=$(date -u -d '+8 hour' '+%Y-%m-%d')
cp -f ./xml/e.xml ./xml/e_$now_date.xml
mv -f ./json/e.json ./json/e_$now_date.json
echo "${{ env.isDiff }}" > ./md5.txt
- name: Commit
if: ${{ env.isDiff }}
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
sed "2c * 更新时间: $(date -u -d '+8 hour' '+%Y-%m-%d %H:%M:%S')" README.md -i
git add --all
git commit -m "update"
git push -f origin ${{ matrix.branch }}