Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit dced98d

Browse files
authored
feat: only create deployment for pull requests (#23)
Also skip setting it to IN_PROGRESS -- just create it and set it to success.
1 parent 9f1a11f commit dced98d

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

bin/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,6 @@ const main = async () => {
102102
}
103103

104104
if (deployingMainApp) {
105-
const deploymentId = await createGithubDeployment({
106-
githubAPIKey,
107-
ref: target.commitSHA,
108-
})
109-
await setGithubDeploymentStatus({
110-
githubAPIKey,
111-
ref: target.commitSHA,
112-
deploymentId,
113-
state: GithubDeploymentState.IN_PROGRESS,
114-
environmentUrl: target.mainAppUrl,
115-
})
116-
117105
await heroku.releaseContainer({
118106
appName: target.mainAppName,
119107
processTypes: ['web', 'worker'],
@@ -145,13 +133,19 @@ const main = async () => {
145133
})
146134
}
147135

148-
await setGithubDeploymentStatus({
149-
githubAPIKey,
150-
ref: target.commitSHA,
151-
deploymentId,
152-
state: GithubDeploymentState.SUCCESS,
153-
environmentUrl: target.mainAppUrl,
154-
})
136+
if (target.hasPullRequest) {
137+
const deploymentId = await createGithubDeployment({
138+
githubAPIKey,
139+
ref: target.commitSHA,
140+
})
141+
await setGithubDeploymentStatus({
142+
githubAPIKey,
143+
ref: target.commitSHA,
144+
deploymentId,
145+
state: GithubDeploymentState.SUCCESS,
146+
environmentUrl: target.mainAppUrl,
147+
})
148+
}
155149
}
156150
}
157151
}

src/targets.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ type Target = {
99
pipelineName: string,
1010
pipelineStage: string,
1111
createAppIfNotExists: boolean,
12+
hasPullRequest: boolean,
1213
}
1314

1415
const getDeploymentTargets = async (): Promise<Target[]> => {
@@ -31,6 +32,7 @@ const getDeploymentTargets = async (): Promise<Target[]> => {
3132
pipelineName,
3233
pipelineStage: 'staging',
3334
createAppIfNotExists: false,
35+
hasPullRequest: false,
3436
},
3537
]
3638
}
@@ -45,6 +47,7 @@ const getDeploymentTargets = async (): Promise<Target[]> => {
4547
pipelineName,
4648
pipelineStage: 'staging',
4749
createAppIfNotExists: false,
50+
hasPullRequest: false,
4851
},
4952
]
5053
}
@@ -59,6 +62,7 @@ const getDeploymentTargets = async (): Promise<Target[]> => {
5962
pipelineName,
6063
pipelineStage: 'production',
6164
createAppIfNotExists: false,
65+
hasPullRequest: false,
6266
},
6367
{
6468
commitSHA,
@@ -69,6 +73,7 @@ const getDeploymentTargets = async (): Promise<Target[]> => {
6973
pipelineName,
7074
pipelineStage: 'production',
7175
createAppIfNotExists: false,
76+
hasPullRequest: false,
7277
},
7378
]
7479
}
@@ -96,6 +101,7 @@ const getDeploymentTargets = async (): Promise<Target[]> => {
96101
pipelineName,
97102
pipelineStage: 'development',
98103
createAppIfNotExists: true,
104+
hasPullRequest: true,
99105
},
100106
]
101107
}

0 commit comments

Comments
 (0)