@@ -2,7 +2,8 @@ import { json } from "@remix-run/node";
2
2
import { z } from "zod" ;
3
3
import { DeleteDeploymentJob } from "~/jobs/delete-deployment-job.server" ;
4
4
import { PushJob } from "~/jobs/push-job.server" ;
5
- import { upsertBranch } from "~/models/branch.server" ;
5
+ import { findBranch , upsertBranch } from "~/models/branch.server" ;
6
+ import { findPullRequestFiles } from "~/models/pull-request.server" ;
6
7
import { type Repository } from "~/models/repository.server" ;
7
8
8
9
type GithubPullRequestEvent = z . infer < typeof GithubPullRequestEventSchema > ;
@@ -14,6 +15,11 @@ export async function processPullRequestWebhook(
14
15
if ( ! repository . deployOnlyOnPullRequest )
15
16
return json ( { message : "No action taken" } ) ;
16
17
18
+ const [ files , branch ] = await findPullRequestData ( ) ;
19
+
20
+ if ( ! branch && ! hasAppsFolderChanges ( ) )
21
+ return json ( { message : "No action taken" } ) ;
22
+
17
23
switch ( webhook . payload . action ) {
18
24
case "opened" :
19
25
case "synchronize" : {
@@ -28,6 +34,20 @@ export async function processPullRequestWebhook(
28
34
return json ( { message : "No action taken" } ) ;
29
35
}
30
36
37
+ function findPullRequestData ( ) {
38
+ return Promise . all ( [
39
+ findPullRequestFiles ( {
40
+ repository,
41
+ prNumber : webhook . payload . number ,
42
+ } ) ,
43
+ findBranch ( branchName ( ) ) ,
44
+ ] ) ;
45
+ }
46
+
47
+ function hasAppsFolderChanges ( ) {
48
+ return files . some ( ( file ) => file . filename . startsWith ( "apps/" ) ) ;
49
+ }
50
+
31
51
async function deploy ( ) {
32
52
await upsertBranch ( {
33
53
branchName : branchName ( ) ,
0 commit comments