Skip to content

Commit e8ab340

Browse files
feat: add /prerelease slash command to trigger publish workflow (#839)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 6504148 commit e8ab340

File tree

5 files changed

+124
-2
lines changed

5 files changed

+124
-2
lines changed

.github/pr-welcome-community.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ As needed or by request, Airbyte Maintainers can execute the following slash com
2727
- `/autofix` - Fixes most formatting and linting issues
2828
- `/poetry-lock` - Updates poetry.lock file
2929
- `/test` - Runs connector tests with the updated CDK
30+
- `/prerelease` - Triggers a prerelease publish with default arguments
3031

3132
If you have any questions, feel free to ask in the PR comments or join our [Slack community](https://airbytehq.slack.com/).

.github/pr-welcome-internal.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Airbyte Maintainers can execute the following slash commands on your PR:
2626
- `/autofix` - Fixes most formatting and linting issues
2727
- `/poetry-lock` - Updates poetry.lock file
2828
- `/test` - Runs connector tests with the updated CDK
29+
- `/prerelease` - Triggers a prerelease publish with default arguments
2930
- `/poe build` - Regenerate git-committed build artifacts, such as the pydantic models which are generated from the manifest JSON schema in YAML.
3031
- `/poe <command>` - Runs any poe command in the CDK environment
3132

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: On-Demand Prerelease
2+
3+
# Minimal permissions for security (addresses GitHub Advanced Security feedback)
4+
permissions:
5+
contents: read
6+
pull-requests: write
7+
issues: write
8+
9+
on:
10+
workflow_dispatch:
11+
inputs:
12+
pr:
13+
description: "PR Number"
14+
type: string
15+
required: false
16+
comment-id:
17+
description: "Comment ID (Optional)"
18+
type: string
19+
required: false
20+
21+
jobs:
22+
prerelease-on-demand:
23+
name: Trigger Prerelease Publish
24+
runs-on: ubuntu-24.04
25+
steps:
26+
- name: Authenticate as GitHub App
27+
uses: actions/create-github-app-token@v2
28+
id: get-app-token
29+
with:
30+
owner: "airbytehq"
31+
repositories: "airbyte-python-cdk"
32+
app-id: ${{ secrets.OCTAVIA_BOT_APP_ID }}
33+
private-key: ${{ secrets.OCTAVIA_BOT_PRIVATE_KEY }}
34+
35+
- name: Create URL to the run output
36+
id: vars
37+
run: echo "run-url=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_OUTPUT
38+
39+
- name: Check that PR number is provided
40+
if: github.event.inputs.pr == ''
41+
run: |
42+
echo "Error: /prerelease command must be invoked on a pull request, not an issue."
43+
exit 1
44+
45+
- name: Get PR info
46+
id: pr-info
47+
run: |
48+
PR_JSON=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.inputs.pr }})
49+
HEAD_REF=$(echo "$PR_JSON" | jq -r .head.ref)
50+
HEAD_REPO=$(echo "$PR_JSON" | jq -r .head.repo.full_name)
51+
echo "head-ref=${HEAD_REF}" >> $GITHUB_OUTPUT
52+
echo "head-repo=${HEAD_REPO}" >> $GITHUB_OUTPUT
53+
echo "PR branch: ${HEAD_REF} from ${HEAD_REPO}"
54+
env:
55+
GH_TOKEN: ${{ steps.get-app-token.outputs.token }}
56+
57+
- name: Check that PR is from this repository (not a fork)
58+
if: steps.pr-info.outputs.head-repo != github.repository
59+
run: |
60+
echo "Error: /prerelease only works for branches in this repository, not forks."
61+
echo "PR is from: ${{ steps.pr-info.outputs.head-repo }}"
62+
echo "Expected: ${{ github.repository }}"
63+
exit 1
64+
65+
- name: Append comment with job run link
66+
if: github.event.inputs.comment-id
67+
id: first-comment-action
68+
uses: peter-evans/create-or-update-comment@v4
69+
with:
70+
comment-id: ${{ github.event.inputs.comment-id }}
71+
issue-number: ${{ github.event.inputs.pr }}
72+
body: |
73+
> **Prerelease Job Info**
74+
>
75+
> This job triggers the publish workflow with default arguments to create a prerelease.
76+
>
77+
> Prerelease job started... [Check job output.][1]
78+
79+
[1]: ${{ steps.vars.outputs.run-url }}
80+
81+
- name: Trigger publish workflow
82+
id: trigger-publish
83+
uses: the-actions-org/workflow-dispatch@v4
84+
with:
85+
workflow: publish.yml
86+
token: ${{ steps.get-app-token.outputs.token }}
87+
ref: ${{ steps.pr-info.outputs.head-ref }}
88+
wait-for-completion: true
89+
display-workflow-run-url: false
90+
inputs: >-
91+
{
92+
"publish_to_pypi": "true",
93+
"publish_to_dockerhub": "true",
94+
"publish_manifest_server": "false",
95+
"update_connector_builder": "false"
96+
}
97+
98+
- name: Append success comment
99+
if: github.event.inputs.comment-id
100+
uses: peter-evans/create-or-update-comment@v4
101+
with:
102+
comment-id: ${{ steps.first-comment-action.outputs.comment-id }}
103+
reactions: hooray
104+
body: |
105+
> ✅ Prerelease workflow triggered successfully.
106+
>
107+
> View the publish workflow run: ${{ steps.trigger-publish.outputs.workflow-url }}
108+
109+
- name: Append failure comment
110+
if: failure() && github.event.inputs.comment-id
111+
uses: peter-evans/create-or-update-comment@v4
112+
with:
113+
comment-id: ${{ steps.first-comment-action.outputs.comment-id }}
114+
reactions: confused
115+
body: |
116+
> ❌ Failed to trigger prerelease workflow.

.github/workflows/publish.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ on:
2020
Note that this workflow is intended for prereleases. For public-facing stable releases,
2121
please use the GitHub Releases workflow instead:
2222
https://github.com/airbytehq/airbyte-python-cdk/blob/main/docs/RELEASES.md.
23-
For prereleases, please leave the version blank to use the detected version. Alternatively,
24-
you can override the dynamic versioning for special use cases.
23+
For prereleases, you can use the /prerelease slash command in a PR comment to trigger
24+
this workflow with default arguments. Alternatively, you can manually trigger this workflow
25+
and leave the version blank to use the detected version, or override the dynamic versioning
26+
for special use cases.
2527
required: false
2628
publish_to_pypi:
2729
description: "Publish to PyPI. If true, the workflow will publish to PyPI."

.github/workflows/slash_command_dispatch.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
test
3636
poetry-lock
3737
poe
38+
prerelease
3839
3940
# Notes regarding static-args:
4041
# - Slash commands can be invoked from both issues and comments.
@@ -63,6 +64,7 @@ jobs:
6364
- \`/autofix\` - Corrects any linting or formatting issues
6465
- \`/test\` - Runs the test suite
6566
- \`/poetry-lock\` - Re-locks dependencies and updates the poetry.lock file
67+
- \`/prerelease\` - Triggers a prerelease publish with default arguments
6668
- \`/help\` - Shows this help message"
6769
6870
if [[ "${{ github.event.comment.body }}" == "/help" ]]; then

0 commit comments

Comments
 (0)