Skip to content

Commit 5df6da7

Browse files
authored
Merge pull request #73 from itsmostafa/fix/workflow-use-pr-for-tracking
feat(workflow): replace issues with docs PR for AWS updates
2 parents d1d3bba + cb77cd8 commit 5df6da7

1 file changed

Lines changed: 97 additions & 3 deletions

File tree

.github/workflows/weekly-aws-doc-check.yml

Lines changed: 97 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,113 @@ jobs:
7676
# Enable auto-merge if the repo allows it
7777
gh pr merge "$PR_URL" --auto --squash || echo "Auto-merge not enabled or not allowed"
7878
79-
- name: Create GitHub issues for updates
79+
- name: Generate docs markdown for updates
8080
if: steps.check.outputs.updates_found == 'true'
81+
id: gen_docs
82+
run: |
83+
python - << 'PY'
84+
import json, os
85+
from pathlib import Path
86+
from datetime import datetime, timezone
87+
updates_file = Path('tracking/pending-updates.json')
88+
if not updates_file.exists():
89+
raise SystemExit(0)
90+
updates = json.loads(updates_file.read_text())
91+
if not updates:
92+
raise SystemExit(0)
93+
# Group by service
94+
by_service = {}
95+
for u in updates:
96+
by_service.setdefault(u.get('service','unknown'), []).append(u)
97+
now = datetime.now(timezone.utc)
98+
date_str = now.strftime('%Y-%m-%d')
99+
docs_dir = Path('docs'); docs_dir.mkdir(parents=True, exist_ok=True)
100+
out = docs_dir / f'aws-updates-{date_str}.md'
101+
if out.exists():
102+
out = docs_dir / f'aws-updates-{now.strftime("%Y-%m-%d-%H%M%S")}.md'
103+
lines = []
104+
lines.append(f'# AWS documentation updates - {date_str}')
105+
lines.append('')
106+
lines.append(f'Total updates: {len(updates)}')
107+
lines.append('')
108+
for service in sorted(by_service.keys()):
109+
lines.append(f'## {service}')
110+
lines.append('')
111+
for u in by_service[service]:
112+
title = u.get('title','(no title)')
113+
link = u.get('link','')
114+
pub = u.get('published','')
115+
lines.append(f'- [{title}]({link}) — published {pub}')
116+
desc = (u.get("description") or '').strip()
117+
if desc:
118+
one_line = ' '.join(desc.splitlines()).strip()
119+
if one_line:
120+
lines.append(f' ')
121+
lines.append(f' {one_line}')
122+
lines.append('')
123+
lines.append('')
124+
out.write_text("\n".join(lines))
125+
print(f'Wrote {out}')
126+
gh_out = os.environ.get('GITHUB_OUTPUT')
127+
if gh_out:
128+
with open(gh_out,'a') as f:
129+
f.write(f'doc_path={out.as_posix()}\n')
130+
f.write(f'doc_date={date_str}\n')
131+
f.write(f'doc_update_count={len(updates)}\n')
132+
PY
133+
134+
- name: Ensure labels exist for docs PR
135+
if: steps.check.outputs.updates_found == 'true'
136+
env:
137+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
138+
run: |
139+
gh label create documentation --description "Documentation updates" --color FFFFFF || true
140+
gh label create aws-update --description "AWS documentation or feature update" --color 1D76DB || true
141+
142+
- name: Create PR for docs update
143+
if: steps.check.outputs.updates_found == 'true'
144+
id: docs_pr
81145
env:
82146
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83-
run: python scripts/generate-update-issues.py
147+
run: |
148+
DOC_PATH="${{ steps.gen_docs.outputs.doc_path }}"
149+
DOC_DATE="${{ steps.gen_docs.outputs.doc_date }}"
150+
UPDATE_COUNT="${{ steps.gen_docs.outputs.doc_update_count }}"
151+
if [ -z "$DOC_PATH" ] || [ ! -f "$DOC_PATH" ]; then
152+
echo "No docs file generated; skipping PR."
153+
exit 0
154+
fi
155+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
156+
git config --local user.name "github-actions[bot]"
157+
BRANCH_NAME="docs/aws-updates-${DOC_DATE}-$(date +%H%M%S)"
158+
git checkout main
159+
git checkout -b "$BRANCH_NAME"
160+
git add "$DOC_PATH"
161+
if git diff --staged --quiet; then
162+
echo "No docs changes to commit"
163+
exit 0
164+
fi
165+
git commit -m "docs: add AWS updates for ${DOC_DATE} (${UPDATE_COUNT})"
166+
git push -u origin "$BRANCH_NAME"
167+
PR_URL=$(gh pr create \
168+
--title "docs: AWS updates for ${DOC_DATE} (${UPDATE_COUNT})" \
169+
--body "Automated summary of AWS documentation updates for ${DOC_DATE}. The new file is ${DOC_PATH}." \
170+
--base main \
171+
--head "$BRANCH_NAME" \
172+
--label "documentation,aws-update")
173+
echo "Created PR: $PR_URL"
174+
echo "pr_url=${PR_URL}" >> "$GITHUB_OUTPUT"
84175
85176
- name: Summary
86177
run: |
87178
echo "## AWS Documentation Check Complete" >> $GITHUB_STEP_SUMMARY
88179
echo "" >> $GITHUB_STEP_SUMMARY
89180
if [ "${{ steps.check.outputs.updates_found }}" == "true" ]; then
90181
echo "Found ${{ steps.check.outputs.update_count }} significant updates." >> $GITHUB_STEP_SUMMARY
91-
echo "GitHub issues have been created for review." >> $GITHUB_STEP_SUMMARY
182+
echo "A pull request with a docs summary has been opened." >> $GITHUB_STEP_SUMMARY
183+
if [ -n "${{ steps.docs_pr.outputs.pr_url }}" ]; then
184+
echo "PR: ${{ steps.docs_pr.outputs.pr_url }}" >> $GITHUB_STEP_SUMMARY
185+
fi
92186
else
93187
echo "No significant updates found." >> $GITHUB_STEP_SUMMARY
94188
fi

0 commit comments

Comments
 (0)