@@ -10,7 +10,7 @@ inputs:
10
10
required : false
11
11
default : ' docs'
12
12
vercel-domain :
13
- description : ' Vercel deployment domain '
13
+ description : ' DEPRECATED - Previously for Vercel, now using different URL format '
14
14
required : false
15
15
default : ' coder-docs-git'
16
16
changed-files :
56
56
exit 1
57
57
fi
58
58
59
+ - name : Debug inputs
60
+ shell : bash
61
+ run : |
62
+ echo "Docs dir: ${{ inputs.docs-dir }}"
63
+ echo "Manifest changed: ${{ inputs.manifest-changed }}"
64
+ echo "First few changed files:"
65
+ echo '${{ inputs.changed-files }}' | jq -r '.[] | select(startswith("${{ inputs.docs-dir }}/"))' | head -n 5
66
+
59
67
- name : Analyze docs changes
60
68
id : docs-analysis
61
69
shell : bash
@@ -67,18 +75,38 @@ runs:
67
75
DOC_FILES_COUNT=$(jq -r '.[] | select(startswith("${{ inputs.docs-dir }}/"))' changed_files.json | wc -l)
68
76
echo "doc_files_count=$DOC_FILES_COUNT" >> $GITHUB_OUTPUT
69
77
70
- # Format changed files for comment
71
- FORMATTED_FILES=$(jq -r '.[] | select(startswith("${{ inputs.docs-dir }}/")) | "- `" + . + "`"' changed_files.json)
78
+ # Force to true for debugging
79
+ DOC_FILES_COUNT=1
80
+
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)
97
+
98
+ # Add a minimum placeholder if no files found
99
+ if [ -z "$FORMATTED_FILES" ]; then
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"
102
+ fi
103
+
72
104
echo "changed_files<<EOF" >> $GITHUB_OUTPUT
73
- echo "$FORMATTED_FILES" >> $GITHUB_OUTPUT
105
+ echo -e "$FORMATTED_FILES" >> $GITHUB_OUTPUT
74
106
echo "EOF" >> $GITHUB_OUTPUT
75
107
76
- # Determine if docs have changed
77
- if [ "$DOC_FILES_COUNT" -gt 0 ]; then
78
- echo "has_changes=true" >> $GITHUB_OUTPUT
79
- else
80
- echo "has_changes=false" >> $GITHUB_OUTPUT
81
- fi
108
+ # Determine if docs have changed - force true for testing
109
+ echo "has_changes=true" >> $GITHUB_OUTPUT
82
110
83
111
# Clean up sensitive file
84
112
rm -f changed_files.json
@@ -88,21 +116,20 @@ runs:
88
116
if : steps.docs-analysis.outputs.has_changes == 'true'
89
117
shell : bash
90
118
run : |
91
- # Get PR number for Vercel preview URL using GitHub event file
92
- PR_NUMBER =$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
119
+ # Get PR branch name for Vercel preview URL
120
+ BRANCH_NAME =$(jq --raw-output .pull_request.head.ref "$GITHUB_EVENT_PATH")
93
121
94
- # Input validation - ensure PR number is a number
95
- if ! [[ "$PR_NUMBER" =~ ^[0-9]+$ ] ]; then
96
- echo "::error::Invalid PR number: $PR_NUMBER "
122
+ # Input validation - ensure branch name is valid
123
+ if [ -z "$BRANCH_NAME" ]; then
124
+ echo "::error::Could not determine branch name "
97
125
exit 1
98
126
fi
99
127
100
- # Generate and output Vercel preview URL with sanitized inputs
101
- VERCEL_DOMAIN="${{ inputs.vercel-domain }}"
102
- # Remove any dangerous characters from domain
103
- VERCEL_DOMAIN=$(echo "$VERCEL_DOMAIN" | tr -cd 'a-zA-Z0-9-.')
128
+ # For debugging
129
+ echo "Branch name: $BRANCH_NAME"
104
130
105
- VERCEL_PREVIEW_URL="https://${VERCEL_DOMAIN}-${PR_NUMBER}.vercel.app"
131
+ # Create the correct Vercel preview URL
132
+ VERCEL_PREVIEW_URL="https://coder.com/docs/@$BRANCH_NAME"
106
133
echo "url=$VERCEL_PREVIEW_URL" >> $GITHUB_OUTPUT
107
134
108
135
- name : Analyze manifest changes
@@ -138,11 +165,12 @@ runs:
138
165
clean_path=${doc_path#./}
139
166
clean_path=$(echo "$clean_path" | tr -cd 'a-zA-Z0-9_./-')
140
167
141
- # Generate preview URL
168
+ # Get branch name for URLs
169
+ BRANCH_NAME=$(jq --raw-output .pull_request.head.ref "$GITHUB_EVENT_PATH")
170
+
171
+ # Generate preview URL with correct format
142
172
url_path=$(echo "$clean_path" | sed 's/\.md$//')
143
- VERCEL_DOMAIN="${{ inputs.vercel-domain }}"
144
- VERCEL_DOMAIN=$(echo "$VERCEL_DOMAIN" | tr -cd 'a-zA-Z0-9-.')
145
- preview_url="https://${VERCEL_DOMAIN}-${PR_NUMBER}.vercel.app/${url_path}"
173
+ preview_url="https://coder.com/docs/@${BRANCH_NAME}/${url_path}"
146
174
147
175
# Extract doc title or use filename safely
148
176
if [ -f "$doc_path" ]; then
0 commit comments