-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add github action for broken link check in connectors element templates
- Loading branch information
Showing
3 changed files
with
442 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Define paths | ||
SOURCE_DIR=tmp-connectors/ | ||
DOCUSAURUS_BASE_URL="https://docs.camunda.io/" | ||
|
||
mkdir $SOURCE_DIR | ||
# Change to the directory where the original files are located | ||
cd "$SOURCE_DIR" || exit 1 | ||
|
||
git clone https://github.com/camunda/connectors.git | ||
|
||
cd connectors | ||
|
||
# Temp file to store extracted links (ensure no duplicates) | ||
TMP_FILE="connector-template-links.md" | ||
> "$TMP_FILE" # Clear file before writing new links | ||
|
||
printf -- "---\n\ | ||
id: connector-template-links\n\ | ||
title: Connector template links check\n\ | ||
hide_title: true\n\ | ||
unlisted: true\n\ | ||
sidebar_class_name: hidden\n\ | ||
---\n\n\ | ||
# This page is autogenerated and contains all links the connector template refer to:\n\n" > "$TMP_FILE" | ||
|
||
echo "extracting links..." | ||
|
||
# Function to extract links from JSON files | ||
extract_links() { | ||
local file_path="$1" | ||
local file_name | ||
file_name=$(basename "$file_path") | ||
|
||
grep -oE "\"$DOCUSAURUS_BASE_URL[^\"]+\"" "$file_path" | sed 's/"//g' | sed 's/[\/\\]*$//' | sed "s|https://docs.camunda.io|[$file_path](|; s|$|)|" | ||
} | ||
|
||
# Call extract links on all json file links in connectors repo | ||
find . -type d -name "element-templates" | while read -r dir; do | ||
find "$dir" -type f -name "*.json" | while read -r file; do | ||
extract_links "$file" | ||
done | ||
done | sort -u >> "$TMP_FILE" # Sort & remove duplicates before writing | ||
|
||
ls | ||
mv connector-template-links.md ${GITHUB_WORKSPACE}/docs/components/connectors/ | ||
|
||
echo "cleaning up..." | ||
|
||
cd ../.. | ||
rm -rf $SOURCE_DIR | ||
|
||
#npm run --silent build 2> >(tee npmOutput.txt | sed 's/\x1B\[[0-9;]*[a-zA-Z]//g' > npmOutput_clean.txt) | ||
#npm run --silent build 2> >(sed 's/\x1B\[[0-9;]*[a-zA-Z]//g' > npmOutput_clean.txt) | ||
ls | ||
echo "Script completed successfully." | ||
exit 0 | ||
|
||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: check-element-template-links | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
types: [opened, synchronize, reopened] #TODO remove, just for testing | ||
schedule: | ||
- cron: "0 3 1 * *" | ||
|
||
jobs: | ||
check-for-element-template-links: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 22 | ||
- name: Install Dependencies | ||
run: npm ci | ||
- name: Cache Docusaurus | ||
uses: ./.github/actions/docusaurus-cache | ||
- name: Collect connector template link | ||
run: | | ||
chmod +x ./.github/scripts/sync-connector-template-links.sh | ||
./.github/scripts/sync-connector-template-links.sh | ||
shell: bash | ||
- name: Build | ||
run: | | ||
npm run build --no-warnings --no-minify 2> >(sed 's/\x1B\[[0-9;]*[a-zA-Z]//g' | sed -n '/\[ERROR\] Error: Unable to build website for locale en\./,$p' > npmOutput_clean.txt) | ||
env: | ||
NODE_OPTIONS: --max_old_space_size=8192 | ||
- name: Create Issue on failure | ||
if: failure() | ||
uses: peter-evans/create-issue-from-file@v4 | ||
with: | ||
title: Connector template link check failed | ||
content-filepath: npmOutput_clean.txt | ||
labels: bug, automated issue |
Oops, something went wrong.