Skip to content

Commit 8d20f79

Browse files
committed
New feature: Adds workflow for SFCC docs update
Adds a GitHub Actions workflow that automates the process of updating SFCC documentation. The workflow: - Is scheduled to run weekly. - Converts SFCC documentation using a Node.js script. - Checks for changes in the `docs/` directory. - Creates a new branch and commits the changes if documentation has been updated. - Opens a pull request to the `develop` branch with a summary of the changes. This automates documentation updates, improving its consistency and keeping it up-to-date.
1 parent 3852991 commit 8d20f79

File tree

1 file changed

+154
-0
lines changed

1 file changed

+154
-0
lines changed

.github/workflows/update-docs.yml

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
name: Update SFCC Documentation
2+
3+
on:
4+
schedule:
5+
# Run weekly on Sundays at 3 AM UTC
6+
- cron: '0 3 * * 0'
7+
workflow_dispatch:
8+
# Allow manual triggering
9+
10+
jobs:
11+
update-docs:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v5
20+
with:
21+
# Use a token with write permissions for creating PRs
22+
token: ${{ secrets.GITHUB_TOKEN }}
23+
fetch-depth: 0
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: '20'
29+
cache: 'npm'
30+
31+
- name: Install dependencies
32+
run: npm ci
33+
34+
- name: Install convert-docs dependencies
35+
run: |
36+
echo "Installing additional dependencies for docs conversion..."
37+
npm install axios cheerio
38+
39+
- name: Configure Git
40+
run: |
41+
git config user.name "github-actions[bot]"
42+
git config user.email "github-actions[bot]@users.noreply.github.com"
43+
44+
- name: Create update branch
45+
run: |
46+
# Create a unique branch name with timestamp
47+
BRANCH_NAME="docs/automated-update-$(date +'%Y%m%d-%H%M%S')"
48+
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
49+
git checkout -b "$BRANCH_NAME"
50+
51+
- name: Run docs conversion
52+
run: |
53+
echo "Starting SFCC documentation conversion..."
54+
npm run convert-docs
55+
echo "Documentation conversion completed"
56+
57+
- name: Check for changes
58+
id: check_changes
59+
run: |
60+
# Check if there are any changes in the docs directory
61+
if git diff --quiet HEAD -- docs/; then
62+
echo "No changes detected in documentation"
63+
echo "has_changes=false" >> $GITHUB_OUTPUT
64+
else
65+
echo "Changes detected in documentation"
66+
echo "has_changes=true" >> $GITHUB_OUTPUT
67+
68+
# Show summary of changes
69+
echo "Changed files:"
70+
git diff --name-only HEAD -- docs/
71+
72+
# Count changes
73+
ADDED=$(git diff --numstat HEAD -- docs/ | awk '{sum += $1} END {print sum}')
74+
DELETED=$(git diff --numstat HEAD -- docs/ | awk '{sum += $2} END {print sum}')
75+
FILES_CHANGED=$(git diff --name-only HEAD -- docs/ | wc -l)
76+
77+
echo "files_changed=$FILES_CHANGED" >> $GITHUB_OUTPUT
78+
echo "lines_added=$ADDED" >> $GITHUB_OUTPUT
79+
echo "lines_deleted=$DELETED" >> $GITHUB_OUTPUT
80+
fi
81+
82+
- name: Commit changes
83+
if: steps.check_changes.outputs.has_changes == 'true'
84+
run: |
85+
git add docs/
86+
git commit -m "docs: automated update of SFCC documentation
87+
88+
- Updated SFCC API documentation from latest sources
89+
- Files changed: ${{ steps.check_changes.outputs.files_changed }}
90+
- Lines added: ${{ steps.check_changes.outputs.lines_added }}
91+
- Lines deleted: ${{ steps.check_changes.outputs.lines_deleted }}
92+
93+
Generated by automated workflow on $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
94+
95+
- name: Push changes
96+
if: steps.check_changes.outputs.has_changes == 'true'
97+
run: |
98+
git push origin "$BRANCH_NAME"
99+
100+
- name: Create Pull Request
101+
if: steps.check_changes.outputs.has_changes == 'true'
102+
run: |
103+
gh pr create \
104+
--title "📚 Automated SFCC Documentation Update" \
105+
--body "## 🤖 Automated Documentation Update
106+
107+
This pull request contains automated updates to the SFCC documentation scraped from the latest Salesforce Commerce Cloud documentation sources.
108+
109+
### 📊 Summary
110+
- **Files changed:** ${{ steps.check_changes.outputs.files_changed }}
111+
- **Lines added:** ${{ steps.check_changes.outputs.lines_added }}
112+
- **Lines deleted:** ${{ steps.check_changes.outputs.lines_deleted }}
113+
- **Generated on:** $(date -u '+%Y-%m-%d %H:%M:%S UTC')
114+
115+
### 🔍 What's Updated
116+
This update includes changes to the SFCC API documentation in the \`docs/\` directory, which may include:
117+
- New or updated class documentation
118+
- Method signature changes
119+
- Property documentation updates
120+
- New API additions or deprecations
121+
122+
### ✅ Review Checklist
123+
- [ ] Review the changed files for accuracy
124+
- [ ] Verify that no important documentation was accidentally removed
125+
- [ ] Check that the documentation format is consistent
126+
- [ ] Ensure all links and references are working correctly
127+
128+
### 🚀 Auto-merge
129+
This PR can be safely merged if the documentation changes look correct and don't break any existing functionality.
130+
131+
---
132+
*This PR was automatically created by the \`update-docs\` GitHub Action workflow.*" \
133+
--base develop \
134+
--head "$BRANCH_NAME" \
135+
--label "documentation,automated,dependencies" \
136+
--assignee taurgis \
137+
--reviewer taurgis
138+
env:
139+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140+
141+
- name: Summary
142+
if: steps.check_changes.outputs.has_changes == 'false'
143+
run: |
144+
echo "✅ No documentation changes detected. The SFCC documentation is up to date."
145+
echo "Workflow completed successfully without creating a pull request."
146+
147+
- name: Cleanup on failure
148+
if: failure()
149+
run: |
150+
echo "❌ Workflow failed. Cleaning up..."
151+
# Delete the branch if it was created but the workflow failed
152+
if [ -n "$BRANCH_NAME" ]; then
153+
git push origin --delete "$BRANCH_NAME" || echo "Branch cleanup failed or branch doesn't exist remotely"
154+
fi

0 commit comments

Comments
 (0)