Skip to content

The open alternative to Salesforce, designed for AI.

External contributor auto-draft and dispatch pr-review event type (#20329)

Paul Rastoina3224880e043
diff --git a/.github/workflows/external-contributor-pr-auto-draft.yaml b/.github/workflows/external-contributor-pr-auto-draft.yaml
new file mode 100644
index 00000000000..5c9e085d1d7
--- /dev/null
+++ b/.github/workflows/external-contributor-pr-auto-draft.yaml
@@ -0,0 +1,42 @@
+name: Auto-Draft External PRs
+
+on:
+ pull_request_target:
+ types: [opened]
+
+permissions:
+ pull-requests: write
+
+jobs:
+ convert-to-draft:
+ if: |
+ github.event.pull_request.draft == false &&
+ github.event.pull_request.author_association != 'MEMBER' &&
+ github.event.pull_request.author_association != 'OWNER' &&
+ github.event.pull_request.author_association != 'COLLABORATOR'
+ runs-on: ubuntu-latest
+ timeout-minutes: 5
+ steps:
+ - name: Convert to draft
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ PR_NODE_ID: ${{ github.event.pull_request.node_id }}
+ run: |
+ gh api graphql -f query="
+ mutation {
+ convertPullRequestToDraft(input: {pullRequestId: \"$PR_NODE_ID\"}) {
+ pullRequest { isDraft }
+ }
+ }
+ "
+
+ - name: Welcome comment
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ PR_NUMBER: ${{ github.event.pull_request.number }}
+ run: |
+ gh pr comment "$PR_NUMBER" --repo ${{ github.repository }} --body "👋 Thanks for contributing to Twenty!
+
+ Your PR has been set to draft while you work on it. Once you're done, mark it as **Ready for review** and our automated checks will run.
+
+ Looking forward to your contribution!"
diff --git a/.github/workflows/pr-auto-review-dispatch.yaml b/.github/workflows/pr-auto-review-dispatch.yaml
new file mode 100644
index 00000000000..0a30c518287
--- /dev/null
+++ b/.github/workflows/pr-auto-review-dispatch.yaml
@@ -0,0 +1,34 @@
+name: PR Review Dispatch
+
+on:
+ pull_request_target:
+ types: [ready_for_review, synchronize]
+
+permissions: {}
+
+concurrency:
+ group: pr-review-${{ github.event.pull_request.number }}
+ cancel-in-progress: true
+
+jobs:
+ dispatch:
+ if: github.event.pull_request.draft == false
+ runs-on: ubuntu-latest
+ timeout-minutes: 5
+ steps:
+ - name: Dispatch to ci-privileged
+ env:
+ GH_TOKEN: ${{ secrets.CI_PRIVILEGED_DISPATCH_TOKEN }}
+ PR_NUMBER: ${{ github.event.pull_request.number }}
+ PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
+ PR_AUTHOR: ${{ github.event.pull_request.user.login }}
+ PR_AUTHOR_ASSOCIATION: ${{ github.event.pull_request.author_association }}
+ REPO: ${{ github.repository }}
+ run: |
+ gh api repos/twentyhq/ci-privileged/dispatches \
+ -f event_type=pr-review \
+ -f "client_payload[pr_number]=$PR_NUMBER" \
+ -f "client_payload[pr_head_sha]=$PR_HEAD_SHA" \
+ -f "client_payload[pr_author]=$PR_AUTHOR" \
+ -f "client_payload[pr_author_association]=$PR_AUTHOR_ASSOCIATION" \
+ -f "client_payload[repo]=$REPO"