Daily Website Request #126
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This is a basic workflow to help you get started with Actions | |
| name: Daily Website Request | |
| # Controls when the workflow will run | |
| on: | |
| # Triggers the workflow on push or pull request events but only for the "master" branch | |
| push: | |
| branches: [ "master" ] | |
| pull_request: | |
| branches: [ "master" ] | |
| schedule: | |
| # 执行时间,北京时间上午10点执行,可根据情况修改。 | |
| - cron: '0 2 * * *' | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| inputs: | |
| debug_enabled: | |
| description: "手动触发" | |
| required: true | |
| default: true | |
| jobs: | |
| request: | |
| runs-on: ubuntu-latest | |
| env: | |
| # 在这里配置你的地址列表,逗号分隔 | |
| URLS: ${{ vars.URLS}} | |
| steps: | |
| - name: Validate URLS | |
| run: | | |
| if [ -z "$URLS" ]; then | |
| echo "❌ ERROR: URLS is empty. Please configure vars.URLS in repository settings." | |
| exit 1 | |
| fi | |
| - name: Curl request to multiple URLs | |
| run: | | |
| IFS=',' read -ra ADDR <<< "$URLS" | |
| failed_requests=0 | |
| for url in "${ADDR[@]}"; do | |
| echo "Requesting $url ..." | |
| # default GET Request | |
| if ! curl -X GET -I --retry 3 --max-time 30 "$url"; then | |
| echo "❌ Failed to request $url" | |
| ((failed_requests++)) | |
| else | |
| echo "✅ Successfully requested $url" | |
| fi | |
| echo "" | |
| sleep 1 | |
| done | |
| if [ $failed_requests -gt 0 ]; then | |
| echo "❌ $failed_requests requests failed out of ${#ADDR[@]} total requests" | |
| exit 1 | |
| else | |
| echo "✅ All ${#ADDR[@]} requests succeeded" | |
| fi |