Skip to content

Commit

Permalink
fix: correct links for access page outside docs (#1235)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunng87 authored Oct 25, 2024
1 parent 380da7c commit 3d416ac
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 2 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/check-cloud-integration-link.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Check GreptimeCloud Integration Links

on:
pull_request:
paths:
- '**/greptimecloud/integrations/**.md'

jobs:
check-links:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v43
with:
files: '**/greptimecloud/integrations/**.md'

- name: Check links
run: |
const fs = require('fs');
// Regular expressions for finding links
const markdownLinkRegex = /\[([^\]]*)\]\(([^)]+)\)/g; // [text](url)
const bareUrlRegex = /<?(https?:\/\/[^\s>]+)>?/g; // http://url or <http://url>
// Get the list of changed files
const changedFiles = `${{ steps.changed-files.outputs.all_changed_files }}`.split(' ').filter(f => f);
let hasErrors = false;
changedFiles.forEach(file => {
if (!file.includes('greptimecloud/integrations')) return;
try {
const content = fs.readFileSync(file, 'utf8');
let match;
// Check markdown style links
while ((match = markdownLinkRegex.exec(content)) !== null) {
const url = match[2];
validateUrl(url, file, match[0]);
}
// Check bare URLs
while ((match = bareUrlRegex.exec(content)) !== null) {
const url = match[1];
validateUrl(url, file, match[0]);
}
} catch (error) {
console.error(`::error file=${file}::Error reading file: ${error.message}`);
hasErrors = true;
}
});
function validateUrl(url, file, fullMatch) {
// Remove any trailing parentheses that might have been caught
url = url.replace(/\)$/, '');
// Ignore URLs that are actually reference-style link definitions
if (url.startsWith('[')) return;
// Check if it's a relative link
if (!url.startsWith('https://')) {
console.error(`::error file=${file}::Found relative link: "${fullMatch}". All links must start with https://`);
hasErrors = true;
}
// Check if link ends with .md
if (url.toLowerCase().endsWith('.md')) {
console.error(`::error file=${file}::Found .md link: "${fullMatch}". Links ending with .md are not allowed`);
hasErrors = true;
}
}
if (hasErrors) {
process.exit(1);
}
shell: node {0}
2 changes: 1 addition & 1 deletion docs/greptimecloud/integrations/dbeaver.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ Input the following connection details:

Click "Test Connection" to verify the connection settings and click "Finish" to save the connection.

For more information on interacting with GreptimeDB using MySQL, refer to the [MySQL protocol documentation](https://docs.greptime.com/nightly/user-guide/protocols/mysql.md).
For more information on interacting with GreptimeDB using MySQL, refer to the [MySQL protocol documentation](https://docs.greptime.com/nightly/user-guide/protocols/mysql).
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ Input the following connection details:

Click "Test Connection" to verify the connection settings and click "Finish" to save the connection.

For more information on interacting with GreptimeDB using MySQL, refer to the [MySQL protocol documentation](https://docs.greptime.com/nightly/user-guide/protocols/mysql.md).
For more information on interacting with GreptimeDB using MySQL, refer to the [MySQL protocol documentation](https://docs.greptime.com/nightly/user-guide/protocols/mysql).

0 comments on commit 3d416ac

Please sign in to comment.