mirror of
https://github.com/Coldsmiles/infstarweb.git
synced 2026-04-23 02:30:41 +08:00
102 lines
2.6 KiB
YAML
102 lines
2.6 KiB
YAML
name: Deploy to GitHub Pages
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
schedule:
|
|
# Every days at 04:00 UTC
|
|
- cron: "0 4 */1 * *"
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
pages: write
|
|
id-token: write
|
|
|
|
concurrency:
|
|
group: pages
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.x"
|
|
|
|
- name: Install Python dependencies
|
|
run: pip install requests tqdm
|
|
|
|
- name: Run statsprocess.py
|
|
env:
|
|
STATS_BASE_URL: ${{ secrets.STATS_BASE_URL }}
|
|
STATS_USER: ${{ secrets.STATS_USER }}
|
|
STATS_PASS: ${{ secrets.STATS_PASS }}
|
|
run: python statsprocess.py
|
|
|
|
- name: Prepare Pages artifact
|
|
run: |
|
|
mkdir -p _site
|
|
rsync -a --delete \
|
|
--exclude '.git/' \
|
|
--exclude '.github/' \
|
|
--exclude 'README.md' \
|
|
--exclude 'statsprocess.py' \
|
|
./ ./_site/
|
|
|
|
- name: Upload Pages artifact
|
|
uses: actions/upload-pages-artifact@v3
|
|
with:
|
|
path: ./_site
|
|
|
|
deploy:
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
steps:
|
|
- name: Deploy to GitHub Pages
|
|
id: deployment
|
|
uses: actions/deploy-pages@v4
|
|
|
|
notify-indexnow:
|
|
needs: deploy
|
|
runs-on: ubuntu-latest
|
|
if: success()
|
|
steps:
|
|
- name: Submit URLs to IndexNow
|
|
if: ${{ env.INDEXNOW_KEY != '' }}
|
|
env:
|
|
INDEXNOW_KEY: ${{ secrets.INDEXNOW_KEY }}
|
|
run: |
|
|
if [ -z "$INDEXNOW_KEY" ]; then
|
|
echo "INDEXNOW_KEY not set, skipping."
|
|
exit 0
|
|
fi
|
|
HOST="bailuyuan.lunadeer.cn"
|
|
curl -s -X POST "https://api.indexnow.org/indexnow" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{
|
|
\"host\": \"${HOST}\",
|
|
\"key\": \"${INDEXNOW_KEY}\",
|
|
\"keyLocation\": \"https://${HOST}/${INDEXNOW_KEY}.txt\",
|
|
\"urlList\": [
|
|
\"https://${HOST}/\",
|
|
\"https://${HOST}/sponsor.html\",
|
|
\"https://${HOST}/stats.html\",
|
|
\"https://${HOST}/join.html\",
|
|
\"https://${HOST}/facilities.html\",
|
|
\"https://${HOST}/doc.html\",
|
|
\"https://${HOST}/map.html\",
|
|
\"https://${HOST}/photo.html\"
|
|
]
|
|
}"
|
|
echo ""
|
|
echo "IndexNow notification sent."
|