mirror of
				https://github.com/tormachris/cf-workers-status-page.git
				synced 2025-11-04 04:46:24 +01:00 
			
		
		
		
	
							
								
								
									
										3
									
								
								.github/workflows/deploy.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.github/workflows/deploy.yml
									
									
									
									
										vendored
									
									
								
							@@ -34,15 +34,18 @@ jobs:
 | 
				
			|||||||
          [ -z "$SECRET_SLACK_WEBHOOK_URL" ] && echo "Secret SECRET_SLACK_WEBHOOK_URL not set, creating dummy one..." && SECRET_SLACK_WEBHOOK_URL="default-gh-action-secret" || true
 | 
					          [ -z "$SECRET_SLACK_WEBHOOK_URL" ] && echo "Secret SECRET_SLACK_WEBHOOK_URL not set, creating dummy one..." && SECRET_SLACK_WEBHOOK_URL="default-gh-action-secret" || true
 | 
				
			||||||
          [ -z "$SECRET_TELEGRAM_API_TOKEN" ] && echo "Secret SECRET_TELEGRAM_API_TOKEN not set, creating dummy one..." && SECRET_TELEGRAM_API_TOKEN="default-gh-action-secret" || true
 | 
					          [ -z "$SECRET_TELEGRAM_API_TOKEN" ] && echo "Secret SECRET_TELEGRAM_API_TOKEN not set, creating dummy one..." && SECRET_TELEGRAM_API_TOKEN="default-gh-action-secret" || true
 | 
				
			||||||
          [ -z "$SECRET_TELEGRAM_CHAT_ID" ] && echo "Secret SECRET_TELEGRAM_CHAT_ID not set, creating dummy one..." && SECRET_TELEGRAM_CHAT_ID="default-gh-action-secret" || true
 | 
					          [ -z "$SECRET_TELEGRAM_CHAT_ID" ] && echo "Secret SECRET_TELEGRAM_CHAT_ID not set, creating dummy one..." && SECRET_TELEGRAM_CHAT_ID="default-gh-action-secret" || true
 | 
				
			||||||
 | 
					          [ -z "$SECRET_DISCORD_WEBHOOK_URL" ] && echo "Secret SECRET_DISCORD_WEBHOOK_URL not set, creating dummy one..." && SECRET_DISCORD_WEBHOOK_URL="default-gh-action-secret" || true
 | 
				
			||||||
        postCommands: |
 | 
					        postCommands: |
 | 
				
			||||||
          yarn kv-gc
 | 
					          yarn kv-gc
 | 
				
			||||||
        secrets: |
 | 
					        secrets: |
 | 
				
			||||||
          SECRET_SLACK_WEBHOOK_URL
 | 
					          SECRET_SLACK_WEBHOOK_URL
 | 
				
			||||||
          SECRET_TELEGRAM_API_TOKEN
 | 
					          SECRET_TELEGRAM_API_TOKEN
 | 
				
			||||||
          SECRET_TELEGRAM_CHAT_ID
 | 
					          SECRET_TELEGRAM_CHAT_ID
 | 
				
			||||||
 | 
					          SECRET_DISCORD_WEBHOOK_URL
 | 
				
			||||||
        environment: production
 | 
					        environment: production
 | 
				
			||||||
      env:
 | 
					      env:
 | 
				
			||||||
        CF_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
 | 
					        CF_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
 | 
				
			||||||
        SECRET_SLACK_WEBHOOK_URL: ${{secrets.SECRET_SLACK_WEBHOOK_URL}}
 | 
					        SECRET_SLACK_WEBHOOK_URL: ${{secrets.SECRET_SLACK_WEBHOOK_URL}}
 | 
				
			||||||
        SECRET_TELEGRAM_API_TOKEN: ${{secrets.SECRET_TELEGRAM_API_TOKEN}}
 | 
					        SECRET_TELEGRAM_API_TOKEN: ${{secrets.SECRET_TELEGRAM_API_TOKEN}}
 | 
				
			||||||
        SECRET_TELEGRAM_CHAT_ID: ${{secrets.SECRET_TELEGRAM_CHAT_ID}}
 | 
					        SECRET_TELEGRAM_CHAT_ID: ${{secrets.SECRET_TELEGRAM_CHAT_ID}}
 | 
				
			||||||
 | 
					        SECRET_DISCORD_WEBHOOK_URL: ${{secrets.SECRET_DISCORD_WEBHOOK_URL}}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,6 +19,7 @@ Also, prepare the following secrets
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
- Cloudflare API token with `Edit Cloudflare Workers` permissions
 | 
					- Cloudflare API token with `Edit Cloudflare Workers` permissions
 | 
				
			||||||
- Slack incoming webhook \(optional\)
 | 
					- Slack incoming webhook \(optional\)
 | 
				
			||||||
 | 
					- Discord incoming webhook \(optional\)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Getting started
 | 
					## Getting started
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -38,6 +39,9 @@ You can either deploy with **Cloudflare Deploy Button** using GitHub Actions or
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
   - Name: SECRET_SLACK_WEBHOOK_URL (optional)
 | 
					   - Name: SECRET_SLACK_WEBHOOK_URL (optional)
 | 
				
			||||||
   - Value: your-slack-webhook-url
 | 
					   - Value: your-slack-webhook-url
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   - Name: SECRET_DISCORD_WEBHOOK_URL (optional)
 | 
				
			||||||
 | 
					   - Value: your-discord-webhook-url
 | 
				
			||||||
   ```
 | 
					   ```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
3. Navigate to the **Actions** settings in your repository and enable them
 | 
					3. Navigate to the **Actions** settings in your repository and enable them
 | 
				
			||||||
@@ -46,7 +50,7 @@ You can either deploy with **Cloudflare Deploy Button** using GitHub Actions or
 | 
				
			|||||||
   ```yaml
 | 
					   ```yaml
 | 
				
			||||||
   settings:
 | 
					   settings:
 | 
				
			||||||
     title: 'Status Page'
 | 
					     title: 'Status Page'
 | 
				
			||||||
     url: 'https://status-page.eidam.dev' # used for Slack messages
 | 
					     url: 'https://status-page.eidam.dev' # used for Slack & Discord messages
 | 
				
			||||||
     logo: logo-192x192.png # image in ./public/ folder
 | 
					     logo: logo-192x192.png # image in ./public/ folder
 | 
				
			||||||
     daysInHistogram: 90 # number of days you want to display in histogram
 | 
					     daysInHistogram: 90 # number of days you want to display in histogram
 | 
				
			||||||
     collectResponseTimes: false # experimental feature, enable only for <5 monitors or on paid plans
 | 
					     collectResponseTimes: false # experimental feature, enable only for <5 monitors or on paid plans
 | 
				
			||||||
@@ -96,6 +100,7 @@ You can clone the repository yourself and use Wrangler CLI to develop/deploy, ex
 | 
				
			|||||||
- create KV namespace and add the `KV_STATUS_PAGE` binding to [wrangler.toml](./wrangler.toml)
 | 
					- create KV namespace and add the `KV_STATUS_PAGE` binding to [wrangler.toml](./wrangler.toml)
 | 
				
			||||||
- create Worker secrets _\(optional\)_
 | 
					- create Worker secrets _\(optional\)_
 | 
				
			||||||
  - `SECRET_SLACK_WEBHOOK_URL`
 | 
					  - `SECRET_SLACK_WEBHOOK_URL`
 | 
				
			||||||
 | 
					  - `SECRET_DISCORD_WEBHOOK_URL`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Workers KV free tier
 | 
					## Workers KV free tier
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,6 +6,7 @@ import {
 | 
				
			|||||||
  getCheckLocation,
 | 
					  getCheckLocation,
 | 
				
			||||||
  getKVMonitors,
 | 
					  getKVMonitors,
 | 
				
			||||||
  setKVMonitors,
 | 
					  setKVMonitors,
 | 
				
			||||||
 | 
					  notifyDiscord,
 | 
				
			||||||
} from './helpers'
 | 
					} from './helpers'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function getDate() {
 | 
					function getDate() {
 | 
				
			||||||
@@ -88,6 +89,15 @@ export async function processCronTrigger(event) {
 | 
				
			|||||||
      event.waitUntil(notifyTelegram(monitor, monitorOperational))
 | 
					      event.waitUntil(notifyTelegram(monitor, monitorOperational))
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Send Discord message on monitor change
 | 
				
			||||||
 | 
					    if (
 | 
				
			||||||
 | 
					      monitorStatusChanged &&
 | 
				
			||||||
 | 
					      typeof SECRET_DISCORD_WEBHOOK_URL !== 'undefined' &&
 | 
				
			||||||
 | 
					      SECRET_DISCORD_WEBHOOK_URL !== 'default-gh-action-secret'
 | 
				
			||||||
 | 
					    ) {
 | 
				
			||||||
 | 
					      event.waitUntil(notifyDiscord(monitor, monitorOperational))
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // make sure checkDay exists in checks in cases when needed
 | 
					    // make sure checkDay exists in checks in cases when needed
 | 
				
			||||||
    if (
 | 
					    if (
 | 
				
			||||||
      (config.settings.collectResponseTimes || !monitorOperational) &&
 | 
					      (config.settings.collectResponseTimes || !monitorOperational) &&
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -90,6 +90,30 @@ export async function notifyTelegram(monitor, operational) {
 | 
				
			|||||||
  })
 | 
					  })
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Visualize your payload using https://leovoel.github.io/embed-visualizer/
 | 
				
			||||||
 | 
					export async function notifyDiscord(monitor, operational) {
 | 
				
			||||||
 | 
					  const payload = {
 | 
				
			||||||
 | 
					    username: `${config.settings.title}`,
 | 
				
			||||||
 | 
					    avatar_url: `${config.settings.url}/${config.settings.logo}`,
 | 
				
			||||||
 | 
					    embeds: [
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        title: `${monitor.name} is ${getOperationalLabel(operational)} ${
 | 
				
			||||||
 | 
					          operational ? ':white_check_mark:' : ':x:'
 | 
				
			||||||
 | 
					        }`,
 | 
				
			||||||
 | 
					        description: `\`${monitor.method ? monitor.method : 'GET'} ${
 | 
				
			||||||
 | 
					          monitor.url
 | 
				
			||||||
 | 
					        }\` - :eyes: [Status Page](${config.settings.url})`,
 | 
				
			||||||
 | 
					        color: operational ? 3581519 : 13632027,
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return fetch(SECRET_DISCORD_WEBHOOK_URL, {
 | 
				
			||||||
 | 
					    body: JSON.stringify(payload),
 | 
				
			||||||
 | 
					    method: 'POST',
 | 
				
			||||||
 | 
					    headers: { 'Content-Type': 'application/json' },
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function useKeyPress(targetKey) {
 | 
					export function useKeyPress(targetKey) {
 | 
				
			||||||
  const [keyPressed, setKeyPressed] = useState(false)
 | 
					  const [keyPressed, setKeyPressed] = useState(false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user