forked from airbytehq/airbyte
-
Notifications
You must be signed in to change notification settings - Fork 3
166 lines (149 loc) · 6.5 KB
/
ai-dev-command.yml
File metadata and controls
166 lines (149 loc) · 6.5 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: AI Dev Playbook Command
# Runs a dev version of an ai-skills playbook against an issue in this repo.
# Triggered via slash command: /ai-dev skills-pr=<PR_NUMBER> playbook=<PLAYBOOK_NAME>
#
# Examples:
# /ai-dev skills-pr=42 playbook=issue_triage
# /ai-dev skills-pr=42 playbook=issue_fix
#
# The dev playbook must already exist in the Devin API (created by the
# dev-playbooks.yml workflow in airbytehq/ai-skills when a PR is opened).
on:
workflow_dispatch:
inputs:
issue:
description: "Issue number to test against"
type: string
required: false
skills-pr:
description: "ai-skills PR number with the dev playbook (named skills-pr to avoid collision with the pr static-arg)"
type: number
required: true
playbook:
description: "Playbook name (e.g. issue_triage, issue_fix)"
type: string
required: true
comment-id:
description: "The comment-id of the slash command. Used to update the comment with the status."
required: false
pr:
description: "PR number (passed by slash command dispatcher, unused)"
type: number
required: false
repo:
description: "Repo (passed by slash command dispatcher)"
required: false
default: "airbytehq/airbyte"
gitref:
description: "Git ref (passed by slash command dispatcher)"
required: false
run-name: "AI Dev Playbook: !${{ github.event.inputs.playbook }}__dev-${{ github.event.inputs.skills-pr }}"
permissions:
contents: read
issues: write
pull-requests: read
jobs:
ai-dev:
runs-on: ubuntu-latest
steps:
- name: Get job variables
id: job-vars
run: |
echo "run-url=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_OUTPUT
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Authenticate as GitHub App
uses: actions/create-github-app-token@v3.0.0
id: get-app-token
with:
owner: "airbytehq"
repositories: "airbyte"
app-id: ${{ secrets.OCTAVIA_BOT_APP_ID }}
private-key: ${{ secrets.OCTAVIA_BOT_PRIVATE_KEY }}
- name: Resolve inputs
id: resolve
env:
INPUT_PR_NUMBER: ${{ inputs.skills-pr }}
INPUT_PLAYBOOK_NAME: ${{ inputs.playbook }}
INPUT_ISSUE_NUMBER: ${{ inputs.issue }}
INPUT_COMMENT_ID: ${{ inputs.comment-id }}
GH_TOKEN: ${{ steps.get-app-token.outputs.token }}
run: |
set -euo pipefail
# Resolve from env vars (safely passed via env: to avoid script injection)
pr_number="$INPUT_PR_NUMBER"
playbook_name="$INPUT_PLAYBOOK_NAME"
issue_number="$INPUT_ISSUE_NUMBER"
comment_id="$INPUT_COMMENT_ID"
# When invoked via slash command, inputs.issue is empty because
# the slash-commands.yml static-args don't include issue=.
# Resolve the issue number from the comment-id via the GitHub API.
if [[ -z "$issue_number" || "$issue_number" == "0" ]] && [[ -n "$comment_id" ]]; then
echo "Resolving issue number from comment-id..."
issue_number=$(curl -s \
-H "Authorization: Bearer $GH_TOKEN" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/$GITHUB_REPOSITORY/issues/comments/$comment_id" \
| jq -r '.issue_url | split("/") | last')
if [[ -z "$issue_number" || "$issue_number" == "null" ]]; then
echo "::warning::Could not resolve issue number from comment-id $comment_id"
issue_number=""
else
echo "Resolved issue number: $issue_number"
fi
fi
if [[ -z "$pr_number" ]]; then
echo "::error::Missing required argument: pr (ai-skills PR number)"
exit 1
fi
if ! [[ "$pr_number" =~ ^[0-9]+$ ]]; then
echo "::error::Invalid pr number: must be digits only"
exit 1
fi
if [[ -z "$playbook_name" ]]; then
echo "::error::Missing required argument: playbook (e.g. issue_triage)"
exit 1
fi
if ! [[ "$playbook_name" =~ ^[a-z0-9_]+$ ]]; then
echo "::error::Invalid playbook name: must match [a-z0-9_]+"
exit 1
fi
dev_macro="!${playbook_name}__dev-${pr_number}"
echo "pr_number=${pr_number}" >> $GITHUB_OUTPUT
echo "playbook_name=${playbook_name}" >> $GITHUB_OUTPUT
echo "issue_number=${issue_number}" >> $GITHUB_OUTPUT
echo "comment_id=${comment_id}" >> $GITHUB_OUTPUT
echo "dev_macro=${dev_macro}" >> $GITHUB_OUTPUT
echo "Resolved inputs:"
echo " PR number: ${pr_number}"
echo " Playbook: ${playbook_name}"
echo " Issue: ${issue_number}"
echo " Dev macro: ${dev_macro}"
- name: Post start comment
if: inputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ steps.get-app-token.outputs.token }}
comment-id: ${{ inputs.comment-id }}
issue-number: ${{ steps.resolve.outputs.issue_number }}
body: |
> **AI Dev Playbook Starting**
>
> Using dev macro `${{ steps.resolve.outputs.dev_macro }}` from [ai-skills PR #${{ steps.resolve.outputs.pr_number }}](https://github.com/airbytehq/ai-skills/pull/${{ steps.resolve.outputs.pr_number }})
> [View workflow run](${{ steps.job-vars.outputs.run-url }})
- name: Run dev playbook
uses: aaronsteers/devin-action@main
with:
comment-id: ${{ steps.resolve.outputs.comment_id }}
issue-number: ${{ steps.resolve.outputs.issue_number }}
playbook-macro: ${{ steps.resolve.outputs.dev_macro }}
devin-token: ${{ secrets.DEVIN_AI_API_KEY }}
github-token: ${{ steps.get-app-token.outputs.token }}
api-version: v3
org-id: ${{ vars.DEVIN_AI_ORG_ID }}
start-message: "🔬 **Dev playbook session starting...** Using dev macro `${{ steps.resolve.outputs.dev_macro }}` from [ai-skills PR #${{ steps.resolve.outputs.pr_number }}](https://github.com/airbytehq/ai-skills/pull/${{ steps.resolve.outputs.pr_number }})"
bypass-approval: "true"
tags: |
ai-oncall
playbook-dev
dev-pr-${{ steps.resolve.outputs.pr_number }}