Skip to content

Web3 URL Link Checker #1466

Web3 URL Link Checker

Web3 URL Link Checker #1466

Workflow file for this run

name: Web3 URL Link Checker
env:
ACTIONS_RUNNER_DEBUG: true
ACTIONS_STEP_DEBUG: true
on:
schedule:
- cron: "0 9,17 * * *" # Every day at 6 PM and 3 AM UTC+8
- cron: "0 2 * * *" # Every day at 11 AM UTC+8
workflow_dispatch: # Manual trigger
jobs:
check-links:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Capture Start Time
id: capture-time
run: |
echo "started_at=$(TZ='Asia/Shanghai' date +'%Y-%m-%d %H:%M:%S %Z')" >> "$GITHUB_OUTPUT"
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
- name: Install dependencies
run: |
npm install node-fetch @actions/core @actions/github
npm install ethstorage-sdk
- name: Check Links
id: link-check
timeout-minutes: 30
env:
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
L1_RPC_MAINNET: ${{ secrets.L1_RPC_MAINNET }}
L1_RPC_SEP: ${{ secrets.L1_RPC_SEP }}
run: |
node << 'EOF'
import core from '@actions/core';
import { checkAllLinks } from './it/scripts/check-links.mjs';
import { links } from './it/data/links.mjs';
import { addLinks } from './it/scripts/add-links.mjs';
async function run() {
let errors = [];
const { links: created, errors: addLinkErrors, summaryTable, l1InfoTable } = await addLinks();
const allLinks = [...links, ...created];
const checkLinkErrors = await checkAllLinks(allLinks);
core.setOutput('static_links_total', String(links.length));
if (summaryTable) {
core.setOutput('summary', summaryTable);
}
if (l1InfoTable) {
core.setOutput('l1_summary', l1InfoTable);
}
if (addLinkErrors.length) {
errors.push(...addLinkErrors);
}
if (checkLinkErrors.size > 0) {
errors.push(...Array.from(checkLinkErrors, ([k,v]) => `${k} -> ${v}`));
}
if (created.length) {
const createdList = created.map(link => `- ${link}`).join('\n');
core.setOutput('created', createdList);
}
if (errors.length) {
const failureList = errors.map(err => `- ${err}`).join('\n');
core.setOutput('failures', failureList);
throw new Error(failureList);
}
}
await run().catch(err => {
const errMsg = err?.stack || err?.message || String(err);
console.error('Error happened:', errMsg);
core.setFailed(errMsg);
process.exit(1);
});
EOF
- name: Send Failure Email
if: ${{ always() && steps.link-check.outcome != 'cancelled' && steps.link-check.outcome != 'success' }}
uses: dawidd6/action-send-mail@v6
with:
server_address: smtp.gmail.com
server_port: 465
convert_markdown: true
username: ${{ secrets.SMTP_USERNAME }}
password: ${{ secrets.SMTP_PASSWORD }}
subject: "❌ Web3Gateway Links Failure"
html_body: |
## 🚨 Link Check Failed
- **Outcome:** `${{ steps.link-check.outcome }}`
- **Triggered By:** `${{ github.event_name }}` at `${{ steps.capture-time.outputs.started_at }}`
---
### Link Failures
${{ steps.link-check.outputs.failures }}
### L1 Gas Prices
${{ steps.link-check.outputs.l1_summary }}
### Cost Summary
${{ steps.link-check.outputs.summary }}
### New Links
${{ steps.link-check.outputs.created }}
_(static link list trimmed · total `${{ steps.link-check.outputs.static_links_total }}` entries)_
to: ${{ secrets.NOTIFICATION_EMAIL }}
from: Web3Gateway
- name: Send Daily Success Email
if: ${{ steps.link-check.outcome == 'success' && steps.link-check.outputs.failures == '' && (github.event.schedule == '0 2 * * *' || github.event_name == 'workflow_dispatch') }}
uses: dawidd6/action-send-mail@v6
with:
server_address: smtp.gmail.com
server_port: 465
convert_markdown: true
username: ${{secrets.SMTP_USERNAME}}
password: ${{secrets.SMTP_PASSWORD}}
subject: "✅ Web3Gateway Links Check Successful"
html_body: |
## ✅ All Links Healthy
- **Outcome:** `${{ steps.link-check.outcome }}`
- **Triggered By:** `${{ github.event_name }}` at `${{ steps.capture-time.outputs.started_at }}`
---
### L1 Gas Prices
${{ steps.link-check.outputs.l1_summary }}
### Cost Summary
${{ steps.link-check.outputs.summary }}
### New Links
${{ steps.link-check.outputs.created }}
_(static link list trimmed · total `${{ steps.link-check.outputs.static_links_total }}` entries)_
to: ${{secrets.NOTIFICATION_EMAIL}}
from: Web3Gateway