This repository was archived by the owner on Jan 10, 2023. It is now read-only.
File tree 2 files changed +20
-2
lines changed
2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,10 @@ module.exports = {
26
26
return git . branch ( )
27
27
}
28
28
function detectPRNumber ( ) {
29
- if ( process . env . CODEBUILD_WEBHOOK_HEAD_REF ) {
29
+ if (
30
+ process . env . CODEBUILD_WEBHOOK_HEAD_REF &&
31
+ process . env . CODEBUILD_SOURCE_VERSION . startsWith ( 'pr/' )
32
+ ) {
30
33
return process . env . CODEBUILD_SOURCE_VERSION . replace ( / ^ p r \/ / , '' )
31
34
}
32
35
return undefined
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ describe('AWS CodeBuild Provider', function() {
55
55
} )
56
56
} )
57
57
58
- it ( 'Test build triggered via Github Webhook' , function ( ) {
58
+ it ( 'Test PR build triggered via Github Webhook' , function ( ) {
59
59
process . env . CODEBUILD_WEBHOOK_HEAD_REF = 'refs/heads/master'
60
60
expect ( codebuild . configuration ( ) ) . toEqual ( {
61
61
service : 'codebuild' ,
@@ -68,6 +68,21 @@ describe('AWS CodeBuild Provider', function() {
68
68
} )
69
69
} )
70
70
71
+ it ( 'Test non-PR build triggered via Github Webhook' , function ( ) {
72
+ process . env . CODEBUILD_WEBHOOK_HEAD_REF = 'refs/heads/master'
73
+ process . env . CODEBUILD_SOURCE_VERSION =
74
+ '39ec2418eca4c539d765574a1c68f3bd77e8c549'
75
+ expect ( codebuild . configuration ( ) ) . toEqual ( {
76
+ service : 'codebuild' ,
77
+ build : 'my-project:e016b9d9-f2c8-4749-8373-7ca673b6d969' ,
78
+ job : 'my-project:e016b9d9-f2c8-4749-8373-7ca673b6d969' ,
79
+ commit : '39ec2418eca4c539d765574a1c68f3bd77e8c549' ,
80
+ branch : 'master' ,
81
+ pr : undefined ,
82
+ slug : 'my-org/my-project' ,
83
+ } )
84
+ } )
85
+
71
86
it ( 'throws if slug cannot be detected' , function ( ) {
72
87
process . env . CODEBUILD_RESOLVED_SOURCE_VERSION =
73
88
'39ec2418eca4c539d765574a1c68f3bd77e8c549'
You can’t perform that action at this time.
0 commit comments