Skip to content

Commit ebd1627

Browse files
committed
Add direct links to changed documentation files
1 parent 3e34ff8 commit ebd1627

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

.github/actions/docs-preview/action.yaml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,31 @@ runs:
7878
# Force to true for debugging
7979
DOC_FILES_COUNT=1
8080
81-
# Format changed files for comment
82-
FORMATTED_FILES=$(jq -r '.[] | select(startswith("${{ inputs.docs-dir }}/")) | "- `" + . + "`"' changed_files.json)
81+
# Get branch name for URLs
82+
BRANCH_NAME=$(jq --raw-output .pull_request.head.ref "$GITHUB_EVENT_PATH")
83+
84+
# Format changed files for comment with clickable links
85+
FORMATTED_FILES=""
86+
while read -r file_path; do
87+
[ -z "$file_path" ] && continue
88+
89+
# Create direct link to file
90+
# Remove .md extension and docs/ prefix for the URL path
91+
url_path=$(echo "$file_path" | sed 's/^docs\///' | sed 's/\.md$//')
92+
file_url="https://coder.com/docs/@${BRANCH_NAME}/${url_path}"
93+
94+
# Add the formatted line with link
95+
FORMATTED_FILES="${FORMATTED_FILES}- [$file_path]($file_url)\n"
96+
done < <(jq -r '.[] | select(startswith("${{ inputs.docs-dir }}/"))' changed_files.json)
8397
8498
# Add a minimum placeholder if no files found
8599
if [ -z "$FORMATTED_FILES" ]; then
86-
FORMATTED_FILES="- Test file - debugging workflow"
100+
# Hardcode a test example that links directly to the parameters.md file
101+
FORMATTED_FILES="- [docs/admin/templates/extending-templates/parameters.md](https://coder.com/docs/@${BRANCH_NAME}/admin/templates/extending-templates/parameters)\n"
87102
fi
88103
89104
echo "changed_files<<EOF" >> $GITHUB_OUTPUT
90-
echo "$FORMATTED_FILES" >> $GITHUB_OUTPUT
105+
echo -e "$FORMATTED_FILES" >> $GITHUB_OUTPUT
91106
echo "EOF" >> $GITHUB_OUTPUT
92107
93108
# Determine if docs have changed - force true for testing

.github/workflows/docs-preview.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
## 📚 Docs Preview
9090
9191
Your documentation changes are available for preview at:
92-
**🔗 [Vercel Preview](${{ steps.docs-preview.outputs.url }})**
92+
**🔗 [Documentation Preview](${{ steps.docs-preview.outputs.url }})**
9393
9494
### Changed Documentation Files
9595
${{ steps.docs-preview.outputs.changed_files }}

0 commit comments

Comments
 (0)