Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct links for access page outside docs #1235

Merged
merged 2 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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).
Loading