Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita4d3d94

Browse files
EdwardAngertclaude
andcommitted
feat: integrate docs-analysis with docs-preview-link workflow
- Replace manual docs analysis with composite action in docs-preview-link- Add missing output fields to docs-analysis action- Update variable references in workflow to use composite outputs- Add integration guide for documentation🤖 Generated with [Claude Code](https://claude.ai/code)Co-Authored-By: Claude <noreply@anthropic.com>
1 parente26a937 commita4d3d94

File tree

3 files changed

+218
-210
lines changed

3 files changed

+218
-210
lines changed
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#Integrating with docs-preview-link Workflow
2+
3+
This guide shows how to integrate the`docs-analysis` composite action with the existing`docs-preview-link.yml` workflow, eliminating duplication and consolidating documentation processing.
4+
5+
##Current State
6+
7+
The docs-preview-link.yml workflow currently embeds document analysis functionality directly in the workflow steps, which leads to:
8+
- Code duplication across workflows
9+
- Harder maintenance when metrics need to be updated
10+
- Inconsistent reporting between workflows
11+
12+
##Integration Strategy
13+
14+
We can refactor the`docs-preview-link.yml` workflow to use our new composite action, bringing these benefits:
15+
- Single source of truth for document analysis
16+
- Consistent metrics across all documentation workflows
17+
- Easier maintenance and feature additions
18+
- Improved security and error handling
19+
20+
##Example Integration
21+
22+
Here's how to replace the verify-docs-changes job in the docs-preview-link.yml workflow with our composite action:
23+
24+
```yaml
25+
verify-docs-changes:
26+
needs:[validate-workflow, delay-start]
27+
runs-on:ubuntu-latest
28+
timeout-minutes:3# Reduced timeout for verification step
29+
if:|
30+
always() &&
31+
(needs.validate-workflow.result == 'success' || needs.validate-workflow.result == 'skipped')
32+
permissions:
33+
contents:read
34+
pull-requests:read
35+
checks:write# For creating check runs
36+
statuses:write# For creating commit statuses
37+
if:|
38+
always() && (
39+
(github.event_name == 'pull_request_target' &&
40+
(github.event.pull_request.draft == false || contains(github.event.pull_request.labels.*.name, 'run-checks-on-draft'))) ||
41+
(github.event_name == 'workflow_dispatch') ||
42+
(github.event_name == 'issue_comment' && github.event.issue.pull_request &&
43+
(contains(github.event.comment.body, '/docs-preview') || contains(github.event.comment.body, '/docs-help')))
44+
)
45+
outputs:
46+
docs_changed:${{ steps.docs-analysis.outputs.docs-changed }}
47+
pr_number:${{ steps.pr_info.outputs.pr_number }}
48+
branch_name:${{ steps.pr_info.outputs.branch_name }}
49+
repo_owner:${{ steps.pr_info.outputs.repo_owner }}
50+
is_fork:${{ steps.pr_info.outputs.is_fork }}
51+
is_comment:${{ steps.pr_info.outputs.is_comment }}
52+
is_manual:${{ steps.pr_info.outputs.is_manual }}
53+
skip:${{ steps.pr_info.outputs.skip }}
54+
execution_start_time:${{ steps.timing.outputs.start_time }}
55+
has_non_docs_changes:${{ steps.docs-analysis.outputs.has-non-docs-changes }}
56+
words_added:${{ steps.docs-analysis.outputs.words-added }}
57+
words_removed:${{ steps.docs-analysis.outputs.words-removed }}
58+
docs_files_count:${{ steps.docs-analysis.outputs.docs-files-count }}
59+
images_added:${{ steps.docs-analysis.outputs.images-added }}
60+
manifest_changed:${{ steps.docs-analysis.outputs.manifest-changed }}
61+
format_only:${{ steps.docs-analysis.outputs.format-only }}
62+
steps:
63+
# Start timing the execution for performance tracking
64+
-name:Capture start time
65+
id:timing
66+
run:|
67+
echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT
68+
echo "::notice::Starting docs preview workflow at $(date)"
69+
70+
# Apply security hardening to the runner
71+
-name:Harden Runner
72+
uses:step-security/harden-runner@latest
73+
with:
74+
egress-policy:audit
75+
76+
-name:Create verification check run
77+
id:create_check
78+
uses:actions/github-script@latest
79+
with:
80+
github-token:${{ secrets.GITHUB_TOKEN }}
81+
script:|
82+
// [existing script code...]
83+
84+
-name:Get PR info
85+
id:pr_info
86+
run:|
87+
# [existing script code to get PR number, branch, etc.]
88+
89+
# Only check out the DEFAULT branch (not the PR code) to verify changes safely
90+
-name:Check out base repository code
91+
if:steps.pr_info.outputs.skip != 'true'
92+
uses:actions/checkout@latest
93+
with:
94+
ref:main# Always use the main branch
95+
fetch-depth:5# Reduce checkout depth for faster runs
96+
sparse-checkout:|
97+
${{ env.DOCS_PRIMARY_PATH }}
98+
*.md
99+
README.md
100+
sparse-checkout-cone-mode:false
101+
102+
# NEW: Use our composite action instead of duplicate logic
103+
-name:Analyze documentation changes
104+
id:docs-analysis
105+
if:steps.pr_info.outputs.skip != 'true'
106+
uses:./.github/actions/docs-analysis
107+
with:
108+
docs-path:${{ env.DOCS_PRIMARY_PATH }}
109+
pr-ref:${{ steps.pr_info.outputs.branch_name }}
110+
base-ref:'main'
111+
significant-words-threshold:${{ env.SIGNIFICANT_WORDS_THRESHOLD }}
112+
throttle-large-repos:'true'
113+
debug-mode:${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug == 'true' || 'false' }}
114+
115+
# Remaining steps can use the outputs from docs-analysis
116+
-name:Update verification status
117+
if:github.event_name == 'pull_request_target' || (github.event_name == 'workflow_dispatch' && steps.pr_info.outputs.skip != 'true')
118+
uses:actions/github-script@latest
119+
with:
120+
github-token:${{ secrets.GITHUB_TOKEN }}
121+
script:|
122+
// [script modified to use step.docs-analysis outputs]
123+
```
124+
125+
## Benefits of Integration
126+
127+
1. **Reduced Duplication**: The core document analysis logic is maintained in one place
128+
2. **Consistent Features**: All documentation workflows get the same analysis capabilities
129+
3. **Better Versioning**: Can pin to specific versions of the docs-analysis action
130+
4. **Cleaner Workflow Files**: Simplified workflow YAML with better separation of concerns
131+
5. **Improved Maintenance**: Changes to analysis logic only need to be made in one place
132+
6. **Common Security Model**: Same input validation and security practices across workflows
133+
134+
## Implementation Plan
135+
136+
1. Create a small PR with the composite action (completed)
137+
2. Test the action in isolation on sample PRs
138+
3. Create a new PR that refactors docs-preview-link.yml to use the composite action
139+
4. Refactor any other documentation workflows to use the same action
140+
5. Establish a process for maintaining the shared action

‎.github/actions/docs-analysis/action.yml‎

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ inputs:
88
description:'Path to the documentation directory'
99
required:false
1010
default:'docs/'
11+
files-pattern:
12+
description:'Glob pattern(s) for documentation files (use vertical bar | to separate multiple patterns)'
13+
required:false
14+
default:'**.md|docs/**'
15+
changed-files:
16+
description:'Comma-separated list of changed files (from tj-actions/changed-files)'
17+
required:false
18+
default:''
1119
pr-ref:
1220
description:'PR reference to analyze (e.g., refs/pull/123/head)'
1321
required:false
@@ -16,10 +24,6 @@ inputs:
1624
description:'Base reference to compare against'
1725
required:false
1826
default:'main'
19-
files-changed:
20-
description:'Comma-separated list of files changed in PR'
21-
required:false
22-
default:''
2327
max-scan-files:
2428
description:'Maximum number of files to scan'
2529
required:false
@@ -44,6 +48,10 @@ inputs:
4448
description:'Enable verbose debugging output'
4549
required:false
4650
default:'false'
51+
use-changed-files-action:
52+
description:'Whether to use tj-actions/changed-files instead of git commands'
53+
required:false
54+
default:'false'
4755

4856
# Define outputs that this action will provide
4957
outputs:
@@ -77,15 +85,27 @@ outputs:
7785
manifest-changed:
7886
description:'Whether manifest.json was changed'
7987
value:${{ steps.verify.outputs.manifest_changed }}
88+
manifest-changed-files:
89+
description:'List of files referenced in manifest changes'
90+
value:${{ steps.verify.outputs.manifest_changed_files }}
8091
format-only:
8192
description:'Whether changes are formatting-only'
8293
value:${{ steps.verify.outputs.format_only }}
8394
significant-change:
8495
description:'Whether changes are significant'
8596
value:${{ steps.verify.outputs.significant_change }}
97+
image-focused:
98+
description:'Whether changes are focused on images'
99+
value:${{ steps.verify.outputs.image_focused }}
86100
has-non-docs-changes:
87101
description:'Whether PR contains non-docs changes'
88102
value:${{ steps.verify.outputs.has_non_docs_changes }}
103+
changed-docs-files:
104+
description:'List of changed docs files'
105+
value:${{ steps.verify.outputs.changed_docs_files }}
106+
docs-dir-files:
107+
description:'List of changed files in docs directory'
108+
value:${{ steps.verify.outputs.docs_dir_files }}
89109
most-changed-file:
90110
description:'Path to the most changed file'
91111
value:${{ steps.find_changed_files.outputs.most_changed_file }}
@@ -256,12 +276,16 @@ runs:
256276
fi
257277
258278
# Determine which files to analyze
259-
if [[ -n "${{ inputs.files-changed }}" ]]; then
260-
# Use provided list of files
279+
if [[ -n "${{ inputs.changed-files }}" ]]; then
280+
# Priority 1: Use files from tj-actions/changed-files
281+
CHANGED_FILES=$(echo "${{ inputs.changed-files }}" | tr ',' '\n')
282+
echo "Using files from tj-actions/changed-files"
283+
elif [[ -n "${{ inputs.files-changed }}" ]]; then
284+
# Priority 2: Use provided list of files (backward compatibility)
261285
CHANGED_FILES=$(echo "${{ inputs.files-changed }}" | tr ',' '\n')
262286
echo "Using provided list of changed files"
263287
else
264-
#Otherwise use git to determine changed files
288+
#Priority 3: Use git to determine changed files
265289
# Skip if git isn't available
266290
if ! command -v git &> /dev/null; then
267291
echo "::warning::Git not available, cannot determine changed files"
@@ -286,6 +310,11 @@ runs:
286310
287311
echo "Checking changed files between $BASE_REF and origin/$BRANCH_NAME"
288312
CHANGED_FILES=$(git diff --name-only origin/$BASE_REF..origin/$BRANCH_NAME)
313+
314+
if [[ "${{ inputs.debug-mode }}" == "true" ]]; then
315+
echo "Files detected via git diff:"
316+
echo "$CHANGED_FILES"
317+
fi
289318
fi
290319
291320
if [[ -z "$CHANGED_FILES" ]]; then
@@ -459,7 +488,7 @@ runs:
459488
if [[ "${{ inputs.debug-mode }}" == "true" ]]; then
460489
set +x
461490
fi
462-
491+
463492
# Analyze document structure for files that have been changed
464493
-name:Analyze document structure
465494
id:analyze_structure

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp