Skip to content

Commit 4142800

Browse files
committed
fix: resolve YAML syntax issues and add Vale configuration
- Fixed YAML syntax in docs-unified.yaml workflow - Added Vale configuration with basic style rules - Created template file approach for PR comment to avoid syntax issues - Ensured proper Vale directory structure
1 parent 83b45fc commit 4142800

File tree

7 files changed

+122
-30
lines changed

7 files changed

+122
-30
lines changed

.github/docs/vale/.vale.ini

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Vale configuration for Coder documentation
2+
StylesPath = .github/docs/vale/styles
3+
4+
# Minimum alert level
5+
MinAlertLevel = suggestion
6+
7+
# Files to analyze
8+
[*.md]
9+
# Vale styles to use
10+
BasedOnStyles = Coder, GitLab
11+
12+
# Disable these specific rules
13+
# Coder.Terms = YES/NO
14+
15+
# Spell checking via Vale
16+
TokenIgnores = (\w+://\S+) # Ignore URLs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
extends: capitalization
2+
message: "'%s' should use title case"
3+
level: warning
4+
scope: heading
5+
match: $title
6+
style: AP # The Associated Press Style Guide
7+
exceptions:
8+
- Coder
9+
- CLI
10+
- API
11+
- UI
12+
- SSH
13+
- URLs
14+
- IP
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
extends: repetition
2+
message: "'%s' is repeated"
3+
level: error
4+
scope: paragraph
5+
ignorecase: true
6+
tokens:
7+
- '[a-z]+'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
extends: metric
2+
message: "Try to keep sentences under 30 words."
3+
level: suggestion
4+
scope: sentence
5+
formula: |
6+
size(tokens)
7+
condition: "> 30"
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
extends: substitution
2+
message: "Use '%s' instead of '%s'"
3+
level: error
4+
ignorecase: false
5+
swap:
6+
"(?<!/)coder": Coder
7+
"docker container": "Docker container"
8+
"kubernetes": Kubernetes
9+
"k8s": Kubernetes
10+
"YAML file": "YAML file"
11+
"yaml file": "YAML file"
12+
"json file": "JSON file"
13+
"markdown file": "Markdown file"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
extends: substitution
2+
message: "Use '%s' instead of '%s'"
3+
level: warning
4+
ignorecase: true
5+
swap:
6+
cannot: can't
7+
"could not": couldn't
8+
"did not": didn't
9+
"do not": don't
10+
"does not": doesn't
11+
"has not": hasn't
12+
"have not": haven't
13+
"is not": isn't
14+
"it is": it's
15+
"should not": shouldn't
16+
"that is": that's
17+
"they are": they're
18+
"was not": wasn't
19+
"we are": we're
20+
"we have": we've
21+
"were not": weren't
22+
"what is": what's
23+
"will not": won't

.github/workflows/docs-unified.yaml

+42-30
Original file line numberDiff line numberDiff line change
@@ -590,52 +590,64 @@ jobs:
590590
591591
echo "::endgroup::"
592592
593-
# Prepare comment for PR
593+
# Prepare comment for PR using a template file approach
594594
- name: Prepare PR comment
595595
id: prepare-comment
596596
if: inputs.post-comment == 'true' && (inputs.pr-number != '' || github.event.pull_request) && steps.changed-files.outputs.all_changed_files != ''
597597
shell: bash
598598
run: |
599599
echo "::group::Preparing PR comment"
600600
601-
# Build the comment
601+
# Variables for template
602602
SANITIZED_BRANCH="${{ steps.context-info.outputs.sanitized_branch }}"
603603
PREVIEW_URL="https://coder.com/docs/@$SANITIZED_BRANCH"
604-
605-
# Create comment header
604+
BADGE="${{ steps.validation-results.outputs.badge }}"
605+
FILES="${{ steps.changed-files.outputs.all_changed_files_count }}"
606+
SUCCESS="${{ steps.validation-results.outputs.success_percentage }}"
607+
PASSING="${{ steps.validation-results.outputs.passing_count }}"
608+
TOTAL="${{ steps.validation-results.outputs.validation_count }}"
609+
DURATION="${{ steps.validation-duration.outputs.duration }}"
610+
WORKFLOW_RUN="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
611+
612+
# Create a temporary file
613+
TEMP_FILE=$(mktemp)
614+
615+
# Create header based on success
606616
if [ "${{ steps.validation-results.outputs.overall_success }}" == "true" ]; then
607-
HEADER="# 📚 Documentation Preview ✅"
608-
STATUS_EMOJI="✅"
617+
echo "# 📚 Documentation Preview ✅" > $TEMP_FILE
618+
EMOJI="✅"
609619
else
610-
HEADER="# 📚 Documentation Preview ⚠️"
611-
STATUS_EMOJI="⚠️"
620+
echo "# 📚 Documentation Preview ⚠️" > $TEMP_FILE
621+
EMOJI="⚠️"
612622
fi
613623
614-
# Build the full comment
615-
COMMENT="$HEADER
616-
617-
## 🖥️ [View Documentation Preview]($PREVIEW_URL)
618-
619-
> ${STATUS_EMOJI} **Validation Result**: ${{ steps.validation-results.outputs.badge }}
620-
621-
### Quick Links
622-
- [Main Docs]($PREVIEW_URL)
623-
- [Installation Guide]($PREVIEW_URL/install)
624-
- [Quickstart]($PREVIEW_URL/tutorials/quickstart)
625-
626-
### 📊 Validation Stats
627-
628-
- **Changed Files**: ${{ steps.changed-files.outputs.all_changed_files_count }} files checked
629-
- **Validation Success**: ${{ steps.validation-results.outputs.success_percentage }}% (${{ steps.validation-results.outputs.passing_count }}/${{ steps.validation-results.outputs.validation_count }} checks passed)
630-
- **Processing Time**: ${{ steps.validation-duration.outputs.duration }}
631-
632-
<sub>⏱️ Validation completed in ${{ steps.validation-duration.outputs.duration }} | [View Workflow Run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})</sub>"
633-
634-
# Save the comment to output
624+
# Add content line by line
625+
echo "" >> $TEMP_FILE
626+
echo "## 🖥️ [View Documentation Preview]($PREVIEW_URL)" >> $TEMP_FILE
627+
echo "" >> $TEMP_FILE
628+
echo "> $EMOJI **Validation Result**: $BADGE" >> $TEMP_FILE
629+
echo "" >> $TEMP_FILE
630+
echo "### Quick Links" >> $TEMP_FILE
631+
echo "- [Main Docs]($PREVIEW_URL)" >> $TEMP_FILE
632+
echo "- [Installation Guide]($PREVIEW_URL/install)" >> $TEMP_FILE
633+
echo "- [Quickstart]($PREVIEW_URL/tutorials/quickstart)" >> $TEMP_FILE
634+
echo "" >> $TEMP_FILE
635+
echo "### 📊 Validation Stats" >> $TEMP_FILE
636+
echo "" >> $TEMP_FILE
637+
echo "- **Changed Files**: $FILES files checked" >> $TEMP_FILE
638+
echo "- **Validation Success**: $SUCCESS% ($PASSING/$TOTAL checks passed)" >> $TEMP_FILE
639+
echo "- **Processing Time**: $DURATION" >> $TEMP_FILE
640+
echo "" >> $TEMP_FILE
641+
echo "<sub>⏱️ Validation completed in $DURATION | [View Workflow Run]($WORKFLOW_RUN)</sub>" >> $TEMP_FILE
642+
643+
# Export content to GitHub output
635644
echo "comment<<EOF" >> $GITHUB_OUTPUT
636-
echo "$COMMENT" >> $GITHUB_OUTPUT
645+
cat $TEMP_FILE >> $GITHUB_OUTPUT
637646
echo "EOF" >> $GITHUB_OUTPUT
638647
648+
# Cleanup
649+
rm $TEMP_FILE
650+
639651
echo "::endgroup::"
640652
641653
# Update the PR comment with results

0 commit comments

Comments
 (0)