10000 docs: add shared docs GitHub action for workflow efficiency by EdwardAngert · Pull Request #17322 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

docs: add shared docs GitHub action for workflow efficiency #17322

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 8 commits into from
Closed
Prev Previous commit
Next Next commit
\Fix docs preview workflow to ensure PR comments are posted\n\nUpdate…
…d to match patterns from the successful pr-deploy.yaml workflow:\n- Added job-level pull-requests write permission\n- Added explicit env var for PR_NUMBER\n- Added explicit GITHUB_TOKEN environment variable\n- Added reactions-edit-mode for consistency\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 1f716c9966c0f809fa02ace22e1e8b2ef49a27a9
23 changes: 19 additions & 4 deletions .github/workflows/docs-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ on:

permissions:
contents: read
pull-requests: write

jobs:
preview:
name: Generate docs preview
runs-on: ubuntu-latest
permissions:
pull-requests: write # needed for commenting on PRs
steps:
- name: Harden Runner
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
Expand All @@ -24,6 +25,16 @@ jobs:
with:
fetch-depth: 0

- name: Get PR info
id: pr_info
run: |
set -euo pipefail
PR_NUMBER=${{ github.event.pull_request.number }}
echo "PR_NUMBER=${PR_NUMBER}" >> $GITHUB_ENV
echo "PR_NUMBER=${PR_NUMBER}" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@27ae6b33eaed7bf87272fdeb9f1c54f9facc9d99 # v45.0.7
Expand All @@ -49,16 +60,19 @@ jobs:
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
issue-number: ${{ env.PR_NUMBER }}
comment-author: 'github-actions[bot]'
body-includes: '## 📚 Docs Preview'
direction: last

- name: Create or update preview comment
if: steps.docs-preview.outputs.has_changes == 'true'
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
issue-number: ${{ env.PR_NUMBER }}
body: |
## 📚 Docs Preview

Expand All @@ -77,4 +91,5 @@ jobs:
---
<sub>🤖 This comment is automatically generated and updated when documentation changes.</sub>
edit-mode: replace
reactions: eyes
reactions: eyes
reactions-edit-mode: replace
Loading
0