File tree Expand file tree Collapse file tree 4 files changed +114
-0
lines changed
Expand file tree Collapse file tree 4 files changed +114
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ set -e
3+
4+ PR_NUMBER=$1
5+ BRANCH_NAME=" docs-update-pr-$PR_NUMBER "
6+
7+ # Ensure we have changes to merge
8+ if [ -z " $( git status --porcelain) " ]; then
9+ echo " No changes to commit"
10+ exit 0
11+ fi
12+
13+ git config user.name " docs-generator[bot]"
14+ git config user.email " docs-generator[bot]@amazon.com"
15+
16+ # Create branch and push
17+ git checkout -b " $BRANCH_NAME "
18+ git add .
19+ git commit -m " Update docs based on PR #$PR_NUMBER
20+
21+ Auto-generated by Q"
22+
23+ git push origin " $BRANCH_NAME "
24+
25+ # Create PR
26+ gh pr create \
27+ --title " Update docs based on PR #$PR_NUMBER " \
28+ --body " Auto-generated documentation updates based on changes in PR #$PR_NUMBER " \
29+ --base main \
30+ --head " $BRANCH_NAME "
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ set -e
3+
4+ PR_NUMBER=$1
5+
6+ # Add PR information
7+ echo " ====== PR Information ======\n" > $PR_FILE
8+ gh pr view $PR_NUMBER --json title,body --jq ' "Title: " + .title + "\nDescription: " + .body' >> $PR_FILE
9+
10+ # Include updated files
11+ echo -e " \n====== Updated files ======\n" >> $PR_FILE
12+ gh pr view $PR_NUMBER --json files --jq " .files[].path" | while read file; do
13+ if [ -f " $file " ]; then
14+ echo " ---- $file ----" >> $PR_FILE
15+ cat " $file " >> $PR_FILE
16+ echo -e " \n" >> $PR_FILE
17+ fi
18+ done
19+
20+
21+
22+
23+
24+
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ set -e
3+
4+ if [ ! -f " $PR_FILE " ]; then
5+ echo " PR file not found, aborting"
6+ exit 1
7+ fi
8+
9+ PROMPT=" Before making any changes, read the 'docs' directory for the project's current
10+ documentation. Then read 'pr-contents.txt' to see the contents of the current PR.\n\n
11+ After reading both the directory and the PR file, update the files in the 'docs' directory
12+ with new documentation reflecting the proposed changes in the PR. Make new files as appropriate."
13+
14+ echo -e $PROMPT | cargo run --bin chat_cli -- chat --non-interactive
Original file line number Diff line number Diff line change 1+ name : docs-generator
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ pr_number :
7+ description : ' Number of PR to document'
8+ required : true
9+ type : string
10+
11+ jobs :
12+ generate_docs :
13+ runs-on : ubuntu-latest
14+ env :
15+ PR_FILE : " pr-contents.txt"
16+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
17+
18+ steps :
19+ - uses : actions/checkout@v4
20+ - name : Install Rust
21+ run : |
22+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
23+ source ~/.cargo/env
24+
25+ - name : Make scripts executable
26+ run : |
27+ chmod +x docs-generation/create-docs-pr.sh
28+ chmod +x docs-generation/read-pr.sh
29+ chmod +x docs-generation/update-docs.sh
30+
31+ - name : Generate PR contents file
32+ run : bash docs-generation/read-pr.sh ${{ inputs.pr_number }}
33+
34+ # For testing purposes, we're building from source
35+ - name : Update docs
36+ run : bash docs-generation/update-docs.sh
37+
38+ - name : Create PR
39+ if : success()
40+ run : bash docs-generation/create-docs-pr.sh ${{ inputs.pr_number }}
41+
42+
43+
44+
45+
46+
You can’t perform that action at this time.
0 commit comments