Automated Task Development with Amazon Q and GitHub Actions
Combining the /dev workflow of Amazon Q Developer with your CI/CD pipeline to optimize efficiency in your SDLC!
- End User: Raises an issue describing the need or problem.
- Product Owner & Business Analyst: Refine the user request and translate it into clear business requirements.
- Technical Lead: Converts business requirements into technical requirements and breaks the task down into smaller pieces.
- Scrum Master: Prioritizes tasks and manages scope.
- Developer: Implements the feature and writes automated tests.
- Tester: Conducts end-user and performance testing.
- Product Owner/BA: Signs off on the release and communicates updates to the customer.
- Customer: Happy with the delivered feature! 🎉
- Ensure Amazon Q only works on a feature branch (never directly on main).
- Enable repository protection mechanisms:
- ✅ No rewriting history
- ✅ No unauthorized merges into main
- ✅ Restrict who can push to main
1
2
3
"As a Front-End Developer, develop a feature that fits the requirements in 'issue_content.txt'.
You are only to use HTML, CSS, and JavaScript as you do not have any frameworks such as Angular or React available.
If needed, use libraries like Bootstrap and jQuery for advanced features."
- The GitHub CLI
- The built-in trigger variable: ${{ github.event.issue.body }}
1
echo "${{ github.event.issue.body }}" > issue_content.txt
- Pull Request Notes – A clear summary of what was changed.
- Commit Message – A meaningful description of the work done.
1
2
3
4
5
6
7
As a Front-End Developer, Develop a feature that fits the requirements in issue_content.txt
You are only to use HTML, CSS, and Javascript as you do not have any frameworks such as angular or react available.
If needed, use libraries like bootstrap and jquery for advanced features.
When you are done:
Put an appropriate commit message in the "commit_message.txt"
Put your pull request notes in "pull_request.txt"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Commit and Push Code
commit_message=$(cat commit_message.txt || echo "Development for issue #${{ github.event.issue.number }}")
git config --global user.email "amazon-q-bot@users.noreply.github.com"
git config --global user.name "Amazon Q Bot"
git add .
git commit -m "#${{ github.event.issue.number }}: ${commit_message}"
git push origin "issue-${{ github.event.issue.number }}"
# Create PR (If none exists)
PR_EXISTS=$(gh pr list --head issue-${{ github.event.issue.number }} --json number -q '.[].number')
if [ -z "$PR_EXISTS" ]; then
PR_BODY=$(cat pull_request.txt|| echo "Feature Development for issue #${{ github.event.issue.number }}")
gh pr create --title "Resolve issue #${{ github.event.issue.number }}" \
--body "$PR_BODY" \
--head "issue-${{ github.event.issue.number }}"
fi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: Amazon Q Feature Development
on:
issues:
types: [labeled]
permissions:
contents: write
issues: write
pull-requests: write
id-token: write
jobs:
AmazonQFeatureDevelopment:
if: github.event.label.name == 'ready-for-ai-development'
runs-on: ubuntu-latest
env:
prompt: |
As a Front-End Developer, Develop a feature that fits the requirements in issue_content.txt
You are only to use HTML, CSS, and Javascript as you do not have any frameworks such as angular or react available.
If needed, use libraries like bootstrap and jquery for advanced features.
When you are done:
Put an appropriate commit message in the "commit_message.txt"
Put your pull request notes in "pull_request.txt"
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_IAM_ROLE }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Create/checkout issue branch
run: |
git fetch --all
BRANCH_NAME="issue-${{ github.event.issue.number }}"
if git ls-remote --heads origin $BRANCH_NAME | grep -q $BRANCH_NAME; then
git checkout $BRANCH_NAME
else
git checkout -b $BRANCH_NAME
fi
- name: Store issue content
run: |
echo "Issue title: ${{ github.event.issue.title }}" >> issue_content.txt
echo "Issue number: ${{ github.event.issue.number }}" >> issue_content.txt
echo "${{ github.event.issue.body }}" >> issue_content.txt
cat issue_content.txt
- name: Remove development label and put issue in progress
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh issue edit ${{ github.event.issue.number }} --remove-label "ready-for-ai-development"
gh issue edit ${{ github.event.issue.number }} --remove-label "ready-for-review" || "No Review Label"
gh issue edit ${{ github.event.issue.number }} --add-label "in-progress" || "Already in progress"
- name: Develop Feature
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl --proto '=https' --tlsv1.2 -sSf https://desktop-release.q.us-east-1.amazonaws.com/latest/amazon-q.deb -o amazon-q.deb
sudo apt install -y ./amazon-q.deb
rm amazon-q.deb
aws s3 sync ${{ secrets.AMAZON_Q_S3_URI }} ~/.local/share/amazon-q
echo "/help" | q chat
q chat -a -- "--command /dev ${{ env.prompt }}"
- name: Commit and push changes
run: |
commit_message=$(cat commit_message.txt || echo "Development for issue #${{ github.event.issue.number }}")
git config --global user.email "amazon-q-bot@users.noreply.github.com"
git config --global user.name "Amazon Q Bot"
git add .
git commit -m "#${{ github.event.issue.number }}: ${commit_message}"
git push origin "issue-${{ github.event.issue.number }}"
- name: Create Pull Request if not exists
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_EXISTS=$(gh pr list --head issue-${{ github.event.issue.number }} --json number -q '.[].number')
if [ -z "$PR_EXISTS" ]; then
PR_BODY=$(cat pull_request.txt)
PR_URL=$(gh pr create --title "Resolve issue #${{ github.event.issue.number }}" \
--body "$PR_BODY" \
--head "issue-${{ github.event.issue.number }}")
gh issue comment ${{ github.event.issue.number }} --body "Pull request created: $PR_URL"
fi
- name: Mark as ready for review
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh issue edit ${{ github.event.issue.number }} --remove-label "in-progress"
gh issue edit ${{ github.event.issue.number }} --add-label "ready-for-review" || "Already in progress"
- Triggering on a Label: I used the label "ready-for-ai-development" as a trigger. This prevents Amazon Q from starting development until the task is fully defined.
- Label Management: Labels help track the AI’s progress and potentially indicate failures if something goes wrong.
- Pull request commenting, always handy.