Files
coder/.github/workflows/docs-preview.yaml
T
Jakub Domeracki e3a1fb0c89 ci: pass github.repository through env var (#24605)
*Disclaimer: implemented by a Coder Agent using Claude Opus 4.*

---

Move `github.repository` from direct `${{ }}` interpolation in the
`run:`
block to an `env:` var, consistent with how `BRANCH` and `PR_NUMBER` are
already handled. This eliminates a `zizmor` template-injection finding.

Follows up on #24283.
2026-04-22 12:57:22 +02:00

44 lines
1.2 KiB
YAML

# This workflow posts a docs preview link as a PR comment whenever a
# pull request that touches files under docs/ is opened. The preview
# is served by coder.com's branch-preview feature at /docs/@<branch>.
#
# Branch names are URL-encoded so that names containing slashes or
# other special characters produce working links.
name: docs-preview
on:
pull_request:
types:
- opened
paths:
- "docs/**"
permissions:
contents: read
jobs:
docs-preview:
runs-on: ubuntu-latest
permissions:
pull-requests: write # needed for commenting on PRs
steps:
- name: Post docs preview comment
env:
GH_TOKEN: ${{ github.token }}
BRANCH: ${{ github.event.pull_request.head.ref }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
run: |
# URL-encode the branch name so slashes and special
# characters don't break the preview URL.
encoded=$(jq -rn --arg b "$BRANCH" '$b | @uri')
url="https://coder.com/docs/@${encoded}"
gh pr comment "${PR_NUMBER}" \
--repo "${REPO}" \
--body "## Docs preview
[:book: View docs preview](${url})
<!-- docs-preview -->"