Skip to content

EPG

EPG #202

Workflow file for this run

name: EPG
on:
schedule:
- cron: 0 4,10,16,22 * * *
- cron: 0,30 15 * * *
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:
- name: download files
run: |
wget https://raw.githubusercontent.com/${{ github.repository }}/${{ matrix.branch }}/md5.txt -O md5.txt
url="${{ matrix.url }}"
if [[ "$url" == *".gz" ]]; then
echo "url is end with gz"
wget $url -O e.xml.gz
gzip -df e.xml.gz
else
echo "url is not end with gz"
wget $url -O e.xml
fi
- name: check md5
run: |
md5=$(md5sum ./e.xml | awk '{print $1}')
if ! grep -q "$md5" ./md5.txt; then
echo "isDiff=$md5" >> $GITHUB_ENV
fi
- name: checkout code
uses: actions/checkout@v4
if: ${{ env.isDiff }}
with:
ref: ${{ matrix.branch }}
path: epg
- name: xml to json
if: ${{ env.isDiff }}
working-directory: epg
run: |
mv -f ../e.xml ./xml/e.xml
pip3 install -r requirements.txt
python3 xml2json.py
- name: move file
if: ${{ env.isDiff }}
working-directory: epg
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 }}
working-directory: epg
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
now_time=$(date -u -d '+8 hour' '+%Y-%m-%d %H:%M:%S')
sed "2c * 更新时间: $now_time" README.md -i
git add --all
git commit -m "$now_time"
git push -f origin ${{ matrix.branch }}