Skip to content

update

update #26

Workflow file for this run

name: update
on:
workflow_dispatch:
schedule:
- cron: '0 2 * * 5'
repository_dispatch:
types: [update]
push:
branches: [main]
paths:
- '/123pan/123pan.py'
- '/docs/main.py'
- '/docs/main2.py'
env:
WEBDAV_URL: ${{ secrets.WEBDAV_URL }}
WEBDAV_ACCOUNT: ${{ secrets.WEBDAV_ACCOUNT }}
WEBDAV_PASSWORD: ${{ secrets.WEBDAV_PASSWORD }}
jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: Set up Python
uses: actions/setup-python@main
with:
python-version: '3.x'
- name: Install dependencies
run: |
python3 -m pip install tqdm
- name: checkout
id: checkout
shell: bash
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
distributions=("graalvm" "corretto" "semeru" "temurin" "zulu" "liberica")
for distribution in "${distributions[@]}"
do
wget -O ./docs/${distribution}.json "https://api.foojay.io/disco/v3.0/packages?distribution=${distribution}"
git add -A
if git diff-index --quiet HEAD --; then
echo "No changes detected for ${distribution}. Moving to next."
continue
else
echo "Changes detected for ${distribution}. Running 'python3 main3.py ${distribution}.json'"
cd ./docs
echo "======================"
python3 main3.py ${distribution}.json
echo "======================"
cd ../
echo 'changed=true' >> $GITHUB_OUTPUT
exit 0
fi
done
echo 'changed=false' >> $GITHUB_OUTPUT
- name: commit
if: steps.checkout.outputs.changed == 'true'
shell: bash
run: |
git add -A
git commit -m "↑updata↑"
- name: Push changes to GitHub
if: steps.checkout.outputs.changed == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
# - name: update 123pan and push changes to 123pan
# if: steps.checkout.outputs.changed == 'true'
# shell: bash
# run: |
# # 拷贝一份 docs 的文件到 123pan目录
# cp -r ./docs/* ./123pan/
# cd ./123pan
# python3 ./123pan.py
# cd ../
# echo "Deleting existing files from WebDAV..."
# curl -u "${WEBDAV_ACCOUNT}:${WEBDAV_PASSWORD}" -X PROPFIND "${WEBDAV_URL}/PCL2-java_download_page/" | \
# grep '<D:href>' | \
# sed 's/.*<D:href>\(.*\)<\/D:href>.*/\1/' | \
# while read -r path; do
# if [[ "$path" != "${WEBDAV_URL}/PCL2-java_download_page/" ]]; then
# curl -u "${WEBDAV_ACCOUNT}:${WEBDAV_PASSWORD}" -X DELETE "${WEBDAV_URL}${path}"
# fi
# done
# echo "Uploading files to WebDAV..."
# find ./123pan -type f | while read -r file; do
# remote_path="${WEBDAV_URL}/PCL2-java_download_page/${file#./123pan/}"
# curl -u "${WEBDAV_ACCOUNT}:${WEBDAV_PASSWORD}" --create-dirs -T "$file" "$remote_path"
# done