4
0
mirror of https://github.com/darkclip/netlist.git synced 2026-11-11 00:34:07 +08:00
netlist/.github/workflows/fetch-better-cf-ip.yml

65 lines
1.9 KiB
YAML

name: fetch-better-cf-ip
on:
push:
branches:
- 'master'
paths:
- '.github/workflows/fetch-better-cf-ip.yml'
workflow_dispatch:
schedule:
- cron: '0 16 1 * *'
jobs:
fetch-better-cf-ip:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check latest release
uses: robinraju/release-downloader@v1
with:
repository: 'XIU2/CloudflareSpeedTest'
latest: true
fileName: 'cfst_*.*'
out-file-path: 'ref1'
- name: Checkout target branch
uses: actions/checkout@v4
with:
ref: better-cf-ip
path: target
- name: Clean target branch
continue-on-error: true
run: rm target/*
- name: Rebuild target branch
run: |
match=cfst
for filepath in ref1/*; do
rename=$(echo $filepath | awk -F'[./]' '{print $2}' | sed "s/$match/cf/g")
exename=$(tar -tf $filepath 2>/dev/null | grep -w $match || true)
if [ ! -z $exename ]; then
echo "Extracting $rename"
tar -xf $filepath $exename -O >./target/$rename
fi
exename=$(unzip -l $filepath 2>/dev/null | awk '{print $4}' | grep -w $match || true)
if [ ! -z $exename ]; then
appendix=$(echo $exename | awk -F'.' '{print $2}')
if [ ! -z $appendix ]; then
rename=$rename.$appendix
fi
echo "Extracting $rename"
unzip -op $filepath $exename >./target/$rename
fi
done
- name: Push to target branch
continue-on-error: true
run: |
cd target
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add .
git commit -m "update $(date +%Y-%m-%d)"
git push -q