8000 docs: test gh preview action on parameters note by EdwardAngert · Pull Request #17319 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

docs: test gh preview action on parameters note #17319

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 11 commits into from
Closed
Changes from 1 commit
Commits
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
Diff view
Prev Previous commit
Next Next commit
\Update preview URL format to match coder.com docs\n\nFix the preview…
… URL format to use the correct format for Coder docs:\n- Changed preview URL to use correct format: https://coder.com/docs/@BRANCH_NAME\n- Updated individual doc links to use same format\n- Marked vercel-domain parameter as deprecated\n\n\ud83e\udd16 Generated with [Claude Code](https://claude.ai/code)\n\nCo-Authored-By: Claude <noreply@anthropic.com>\
  • Loading branch information
EdwardAngert committed Apr 9, 2025
commit 3e34ff8ce73e633f24312f90c86ade6dd35778f4
30 changes: 15 additions & 15 deletions .github/actions/docs-preview/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ inputs:
required: false
default: 'docs'
vercel-domain:
description: 'Vercel deployment domain'
description: 'DEPRECATED - Previously for Vercel, now using different URL format'
required: false
default: 'coder-docs-git'
changed-files:
Expand Down Expand Up @@ -101,21 +101,20 @@ runs:
if: steps.docs-analysis.outputs.has_changes == 'true'
shell: bash
run: |
# Get PR number for Vercel preview URL using GitHub event file
PR_NUMBER=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
# Get PR branch name for Vercel preview URL
BRANCH_NAME=$(jq --raw-output .pull_request.head.ref "$GITHUB_EVENT_PATH")

# Input validation - ensure PR number is a number
if ! [[ "$PR_NUMBER" =~ ^[0-9]+$ ]]; then
echo "::error::Invalid PR number: $PR_NUMBER"
# Input validation - ensure branch name is valid
if [ -z "$BRANCH_NAME" ]; then
echo "::error::Could not determine branch name"
exit 1
fi

# Generate and output Vercel preview URL with sanitized inputs
VERCEL_DOMAIN="${{ inputs.vercel-domain }}"
# Remove any dangerous characters from domain
VERCEL_DOMAIN=$(echo "$VERCEL_DOMAIN" | tr -cd 'a-zA-Z0-9-.')
# For debugging
echo "Branch name: $BRANCH_NAME"

VERCEL_PREVIEW_URL="https://${VERCEL_DOMAIN}-${PR_NUMBER}.vercel.app"
# Create the correct Vercel preview URL
VERCEL_PREVIEW_URL="https://coder.com/docs/@$BRANCH_NAME"
echo "url=$VERCEL_PREVIEW_URL" >> $GITHUB_OUTPUT

- name: Analyze manifest changes
Expand Down Expand Up @@ -151,11 +150,12 @@ runs:
clean_path=${doc_path#./}
clean_path=$(echo "$clean_path" | tr -cd 'a-zA-Z0-9_./-')

# Generate preview URL
# Get branch name for URLs
BRANCH_NAME=$(jq --raw-output .pull_request.head.ref "$GITHUB_EVENT_PATH")

# Generate preview URL with correct format
url_path=$(echo "$clean_path" | sed 's/\.md$//')
VERCEL_DOMAIN="${{ inputs.vercel-domain }}"
VERCEL_DOMAIN=$(echo "$VERCEL_DOMAIN" | tr -cd 'a-zA-Z0-9-.')
preview_url="https://${VERCEL_DOMAIN}-${PR_NUMBER}.vercel.app/${url_path}"
preview_url="https://coder.com/docs/@${BRANCH_NAME}/${url_path}"

# Extract doc title or use filename safely
if [ -f "$doc_path" ]; then
Expand Down
Loading
0