|
16 | 16 | type: number
|
17 | 17 | required: false
|
18 | 18 | comment-text:
|
19 |
| - description: "Full comment text (optional, unused)" |
| 19 | + description: "Full comment text (ignored)" |
20 | 20 | type: string
|
21 | 21 | required: false
|
22 | 22 |
|
23 | 23 | jobs:
|
24 |
| - generate-on-demand: |
| 24 | + run-poe-command: |
25 | 25 | runs-on: ubuntu-latest
|
26 |
| - steps: |
27 |
| - - name: Create URL to the run output |
28 |
| - id: vars |
29 |
| - run: echo "run-url=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_OUTPUT |
30 |
| - |
31 |
| - # Setup for existing PR if PR number is provided |
32 |
| - - name: Get PR info (existing PR) |
33 |
| - id: pr-info |
34 |
| - if: ${{ github.event.inputs.pr }} |
35 |
| - run: | |
36 |
| - PR_JSON=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.inputs.pr }}) |
37 |
| - echo "repo=$(echo "$PR_JSON" | jq -r .head.repo.full_name)" >> $GITHUB_OUTPUT |
38 |
| - echo "branch=$(echo "$PR_JSON" | jq -r .head.ref)" >> $GITHUB_OUTPUT |
39 |
| - env: |
40 |
| - GH_TOKEN: ${{ github.token }} |
41 |
| - |
42 |
| - - name: Append comment with job run link (existing PR) |
43 |
| - id: first-comment-action |
44 |
| - if: ${{ github.event.inputs.comment-id }} |
45 |
| - uses: peter-evans/create-or-update-comment@v4 |
46 |
| - with: |
47 |
| - comment-id: ${{ github.event.inputs.comment-id }} |
48 |
| - issue-number: ${{ github.event.inputs.pr }} |
49 |
| - body: | |
50 |
| - > **Generate Job Info** |
51 |
| - > |
52 |
| - > This job attempts to generate mappings for source '${{ github.event.inputs.source_name }}' using `morph generate` command. If any changes |
53 |
| - > are made, those changes will be automatically committed and pushed back to the PR. |
54 |
| - > |
55 |
| - > Note: This job can only be run by maintainers. On PRs from forks, this command requires |
56 |
| - > that the PR author has enabled the `Allow edits from maintainers` option. |
57 |
| -
|
58 |
| - > Generate job started... [Check job output.][1] |
59 |
| -
|
60 |
| - [1]: ${{ steps.vars.outputs.run-url }} |
61 |
| -
|
62 |
| - - name: Checkout (new PR) |
63 |
| - if: ${{ ! github.event.inputs.pr }} |
64 |
| - uses: actions/checkout@v4 |
65 |
| - with: |
66 |
| - token: ${{ github.token }} |
67 |
| - |
68 |
| - # Setup for new PR if no PR number is provided |
69 |
| - - name: Create branch (new PR) |
70 |
| - id: new-branch |
71 |
| - if: ${{ ! github.event.inputs.pr }} |
72 |
| - run: | |
73 |
| - TIMESTAMP=$(date +%s) |
74 |
| - SOURCE_NAME="${{ github.event.inputs.source_name }}" |
75 |
| - BRANCH_NAME="devin/${TIMESTAMP}-generate-${SOURCE_NAME}" |
76 |
| - echo "branch=$BRANCH_NAME" >> $GITHUB_OUTPUT |
77 |
| - git checkout -b $BRANCH_NAME |
78 |
| -
|
79 |
| - # Checkout repository |
80 |
| - - name: Checkout (existing PR) |
81 |
| - if: ${{ ! github.event.inputs.pr }} |
82 |
| - uses: actions/checkout@v4 |
83 |
| - with: |
84 |
| - ref: ${{ steps.pr-info.outputs.branch }} |
85 |
| - repository: ${{ steps.pr-info.outputs.repo }} |
86 |
| - token: ${{ github.token }} |
87 |
| - |
88 |
| - # Setup Python environment |
89 |
| - - name: Set up Python |
90 |
| - uses: actions/setup-python@v5 |
91 |
| - with: |
92 |
| - python-version: "3.11" |
93 |
| - |
94 |
| - - name: Setup uv |
95 |
| - uses: astral-sh/setup-uv@v5 |
96 |
| - with: |
97 |
| - python-version: "3.11" |
98 |
| - |
99 |
| - - name: Create virtual environment |
100 |
| - run: uv venv |
101 |
| - |
102 |
| - - name: Install poethepoet |
103 |
| - run: uv tool install poethepoet |
104 | 26 |
|
105 |
| - - name: Install dependencies |
106 |
| - run: poe install |
107 |
| - |
108 |
| - # Run the generate command |
109 |
| - - name: Run generate command |
110 |
| - id: generate |
111 |
| - env: |
112 |
| - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |
113 |
| - GCP_GSM_CREDENTIALS: ${{ secrets.GCP_GSM_CREDENTIALS }} |
114 |
| - run: | |
115 |
| - # Run morph generate with the provided source_name and default project_name |
116 |
| - uv run morph build ${{ github.event.inputs.source_name || 'klaviyo' }} --with-generate |
117 |
| -
|
118 |
| - # Store the exit code |
119 |
| - GENERATE_EXIT_CODE=$? |
120 |
| - echo "exit_code=$GENERATE_EXIT_CODE" >> $GITHUB_OUTPUT |
121 |
| -
|
122 |
| - if [ $GENERATE_EXIT_CODE -ne 0 ]; then |
123 |
| - echo "Generate command failed with exit code $GENERATE_EXIT_CODE" |
124 |
| - echo "generate_success=false" >> $GITHUB_ENV |
125 |
| - exit 0 |
126 |
| - else |
127 |
| - echo "Generate command succeeded" |
128 |
| - echo "generate_success=true" >> $GITHUB_ENV |
129 |
| - fi |
130 |
| -
|
131 |
| - # Handle git operations only if generate was successful |
132 |
| - - name: Commit and push changes |
133 |
| - env: |
134 |
| - GH_TOKEN: ${{ github.token }} |
135 |
| - run: | |
136 |
| - # Configure git |
137 |
| - git config --global user.name "GitHub Actions" |
138 |
| - git config --global user.email "[email protected]" |
139 |
| -
|
140 |
| - # Add changes |
141 |
| - git add . |
142 |
| -
|
143 |
| - # Check if there are any changes |
144 |
| - if git diff --staged --quiet; then |
145 |
| - echo "Changes found after running generate command." |
146 |
| - echo "no_changes=false" >> $GITHUB_OUTPUT |
147 |
| -
|
148 |
| - # Commit changes |
149 |
| - git commit -m "Generate mappings for ${{ github.event.inputs.source_name }} source" |
150 |
| -
|
151 |
| - # Push changes |
152 |
| - git push origin HEAD |
153 |
| - else |
154 |
| - echo "No changes found after running generate command." |
155 |
| - echo "no_changes=true" >> $GITHUB_OUTPUT |
156 |
| - fi |
157 |
| -
|
158 |
| - TITLE="feat(morph): Generate mappings for ${{ github.event.inputs.source_name }}" |
159 |
| - BODY="Generate mappings for source: ${{ github.event.inputs.source_name }}, project: airbyte-interop. Link to Devin run: https://app.devin.ai/sessions/f4d085b23ec0438fab16a8e988a1b8eb. Requested by: Aaron (\"AJ\") Steers ([email protected])" |
160 |
| -
|
161 |
| - # Create PR |
162 |
| - PR_URL=$(gh pr create \ |
163 |
| - --title "$TITLE" \ |
164 |
| - --body "$BODY" \ |
165 |
| - --repo ${{ github.repository }}) |
166 |
| -
|
167 |
| - echo "pr_url=$PR_URL" >> $GITHUB_OUTPUT |
168 |
| -
|
169 |
| - # Success/failure comments for existing PR |
170 |
| - - name: Append success comment (existing PR) |
171 |
| - uses: peter-evans/create-or-update-comment@v4 |
172 |
| - if: ${{ success() && github.event.inputs.comment-id }} |
173 |
| - with: |
174 |
| - comment-id: ${{ github.event.inputs.comment-id }} |
175 |
| - reactions: hooray |
176 |
| - body: | |
177 |
| - > ✅ Generate command completed successfully. |
178 |
| -
|
179 |
| - - name: Append failure comment (existing PR) |
180 |
| - uses: peter-evans/create-or-update-comment@v4 |
181 |
| - if: ${{ failure() && github.event.inputs.comment-id }} |
| 27 | + steps: |
| 28 | + - name: Run Poe Slash Command Processor |
| 29 | + uses: aaronsteers/poe-command-processor@main |
182 | 30 | with:
|
| 31 | + command: "morph-generate ${{ github.event.inputs.source_name }}" |
| 32 | + pr: ${{ github.event.inputs.pr }} |
183 | 33 | comment-id: ${{ github.event.inputs.comment-id }}
|
184 |
| - reactions: confused |
185 |
| - body: | |
186 |
| - > ❌ Generate command failed. |
187 |
| -
|
188 |
| - # Success/failure messages for new PR |
189 |
| - - name: Success message for new PR |
190 |
| - if: ${{ github.event_name == 'workflow_dispatch' && success() && steps.create-pr.outputs.pr_url }} |
191 |
| - run: | |
192 |
| - echo "✅ Generate command completed successfully." | tee $GITHUB_JOB_SUMMARY |
193 |
| - echo "PR created: ${{ steps.create-pr.outputs.pr_url }}" | tee $GITHUB_JOB_SUMMARY |
| 34 | + github-token: ${{ secrets.GH_PAT_MAINTENANCE_OCTAVIA }} |
0 commit comments