8000 docs: unify documentation workflows with improved validation by EdwardAngert · Pull Request #17522 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

docs: unify documentation workflows with improved validation #17522

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

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d0fe1f8
Add simplified docs preview GitHub action
EdwardAngert Apr 9, 2025
3010c77
Merge branch 'main' into simplified-docs-preview
EdwardAngert Apr 9, 2025
afbdde9
\Fix tj-actions/changed-files SHA to match existing usage\n\nUpdate t…
EdwardAngert Apr 9, 2025
1f716c9
\Fix docs preview workflow to ensure PR comments are posted\n\nUpdate…
EdwardAngert Apr 9, 2025
38cfd56
\Update preview URL format and add direct doc links\
EdwardAngert Apr 9, 2025
e072e92
Add shared docs GitHub action
EdwardAngert Apr 9, 2025
07e93b0
test: Add heading to docs README
EdwardAngert Apr 9, 2025
6a7a2bc
Add test workflow
EdwardAngert Apr 9, 2025
4fcb322
Unified documentation workflow
EdwardAngert Apr 23, 2025
777bddc
Enhance documentation workflows with cross-reference checking
EdwardAngert Apr 23, 2025
992c592
Enhance PR comment with informative status overview and collapsible s…
EdwardAngert Apr 23, 2025
6420b3f
Optimize workflow logic and improve Vale style checking
EdwardAngert Apr 23, 2025
0a464f3
enhance: optimize workflow with unified reporting and concurrency
EdwardAngert Apr 23, 2025
3840432
refactor: replace linkspector with lychee for link checking
EdwardAngert Apr 23, 2025
b555621
refactor: combine documentation workflow optimizations
EdwardAngert Apr 23, 2025
00a4fb0
fix: address workflow issues for GitHub Actions compatibility
EdwardAngert Apr 23, 2025
ba403f2
docs: update GitHub Actions documentation
EdwardAngert Apr 23, 2025
168b54b
Merge branch 'main' into feature/unified-docs-workflow-combined
EdwardAngert Apr 23, 2025
6a0c1c1
fix: remove duplicate docs example workflows and fix caching issues
EdwardAngert Apr 23, 2025
8a29450
fix: update lychee-action configuration for v1 compatibility
EdwardAngert Apr 23, 2025
e37cda8
fix readme
EdwardAngert Apr 23, 2025
749d142
fix: correct YAML syntax in docs-link-check.yaml
EdwardAngert Apr 23, 2025
90a9ca8
chore: use caret versioning for tj-actions/changed-files
EdwardAngert Apr 23, 2025
bb9e393
fix: update actions and preview URL handling
EdwardAngert Apr 23, 2025
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
Prev Previous commit
Next Next commit
fix: address workflow issues for GitHub Actions compatibility
- Fix branch name extraction with fallbacks for CI environments
- Add conditional handling for PR context in docs-unified workflow
- Improve error handling in cross-reference validation
- Use fixed string matching instead of regex for safer pattern matching
- Remove hardcoded assignee in favor of team assignments
- Improve JSON parsing with proper error handling for lychee results
- Add more reliable newline handling for GitHub issue creation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
  • Loading branch information
EdwardAngert and claude committed Apr 23, 2025
commit 00a4fb03d48ff9003680eb8e9cdd0574b88c7efc
27 changes: 18 additions & 9 deletions .github/actions/docs-shared/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,8 @@ runs:
echo "status=success" >> $GITHUB_OUTPUT
echo "result=" >> $GITHUB_OUTPUT

# Setup regex patterns for cross-references
MD_LINK_PATTERN='\[([^\]]+)\]\(([^)]+)\)'
# Setup regex patterns for cross-references (escape special regex characters)
MD_LINK_PATTERN='\[[^\]]+\]\([^)]+\)'
ANCHOR_LINK_PATTERN='\(#[^)]+\)'

# Get the base commit to compare against
Expand All @@ -474,8 +474,14 @@ runs:

# Check if file exists in commit
if git cat-file -e $commit:$file 2>/dev/null; then
git show $commit:$file | grep -E '^#{1,6} ' | sed 's/^#* //' | tr -d '`' | \
tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9 -]//g' | sed 's/ /-/g'
# Extract and process headings with error handling
git show $commit:$file 2>/dev/null | grep -E '^#{1,6} ' |
while IFS= read -r line; do
echo "$line" | sed 's/^#* //' | tr -d '`' |
tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9 -]//g' | sed 's/ /-/g' || echo ""
done
else
echo "File not found in commit: $file@$commit" >&2
fi
}

Expand Down Expand Up @@ -537,9 +543,10 @@ runs:
for heading in $old_headings; do
if ! echo "$new_headings" | grep -q "$heading"; then
# This heading was removed or changed
# Look for references to this heading
sanitized=${heading//\//\\/} # Escape / for grep
refs=$(grep -r --include="*.md" -l "#$sanitized)" . || echo "")
# Look for references to this heading with proper escaping
# Use grep -F for fixed string matching instead of regex
sanitized="${heading}"
refs=$(grep -r --include="*.md" -F -l "#$sanitized)" . || echo "")

if [ -n "$refs" ]; then
for ref_file in $refs; do
Expand Down Expand Up @@ -573,8 +580,10 @@ runs:
id: generate-preview
shell: bash
run: |
# Simple branch name extraction and URL generation
BRANCH=$(git rev-parse --abbrev-ref HEAD | sed 's/[^a-zA-Z0-9_-]/-/g')
# Robust branch name extraction with fallbacks for CI environments
BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" | sed 's/[^a-zA-Z0-9_-]/-/g')
# Store branch for other steps
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
echo "url=https://coder.com/docs/@$BRANCH" >> $GITHUB_OUTPUT

# Generate direct links to changed docs
Expand Down
19 changes: 16 additions & 3 deletions .github/workflows/docs-link-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@ jobs:
if [ -f "./lychee-result.json" ]; then
echo "Reading link check results from lychee-result.json"

# Count broken links - lychee format is different from linkspector
BROKEN_LINKS=$(jq '.data.failed | length' "./lychee-result.json")
# Count broken links with error handling
BROKEN_LINKS=0
if jq -e '.data.failed' "./lychee-result.json" > /dev/null 2>&1; then
BROKEN_LINKS=$(jq '.data.failed | length' "./lychee-result.json" || echo "0")
fi
echo "broken_links=$BROKEN_LINKS" >> $GITHUB_OUTPUT

if [ "$BROKEN_LINKS" -gt 0 ]; then
Expand Down Expand Up @@ -130,6 +133,15 @@ jobs:
ISSUE_CONTENT+="2. Update the link if needed or remove it\n"
ISSUE_CONTENT+="3. If the link is valid but fails the check, consider adding it to the ignore list in `.github/docs/.lycheeignore`\n\n"

# Use cat with heredoc instead of echo -e for more reliable newline handling
cat << 'EOT' >> /tmp/issue-guidance.txt
### Additional Guidance
- For 404 errors: Check if the resource was moved or renamed
- For timeout errors: The site might be temporarily down, consider retrying
- For redirect issues: Update to the final URL
EOT
ISSUE_CONTENT+=$(cat /tmp/issue-guidance.txt)

ISSUE_CONTENT+="### For Broken Cross-References\n\n"
ISSUE_CONTENT+="1. Update references to deleted or renamed files\n"
ISSUE_CONTENT+="2. Update references to removed headings\n"
Expand Down Expand Up @@ -164,7 +176,8 @@ jobs:
documentation
bug
needs-triage
assignees: EdwardAngert # Assign to docs team lead
# Configure assignee through CODEOWNERS or a team instead of hardcoding
# Additional reviewers can be added in codeowners file or docs team

# Log result for troubleshooting
- name: Log issue creation status
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docs-unified.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
# Phase 2: Prepare PR Information
- name: Get PR info
id: pr_info
if: github.event.pull_request
run: |
set -euo pipefail
PR_NUMBER=${{ github.event.pull_request.number }}
Expand Down
0