diff --git a/index.js b/index.js index f03bc451..bec2a116 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,7 @@ const process = require('process'); // eslint-disable-line node/prefer-global/pr const git = require('./services/git'); const services = { + amplify: require('./services/amplify'), appveyor: require('./services/appveyor'), bamboo: require('./services/bamboo'), bitbucket: require('./services/bitbucket'), diff --git a/services/amplify.js b/services/amplify.js new file mode 100644 index 00000000..97f46504 --- /dev/null +++ b/services/amplify.js @@ -0,0 +1,18 @@ +// https://docs.aws.amazon.com/amplify/latest/userguide/environment-variables.html + +module.exports = { + detect({env}) { + return Boolean(env.AWS_APP_ID); + }, + configuration({env}) { + return { + name: 'AWS Amplify', + service: 'amplify', + commit: env.AWS_COMMIT_ID, + build: env.CODEBUILD_BUILD_ID, + branch: env.AWS_BRANCH, + buildUrl: env.CODEBUILD_BUILD_URL, + root: env.PWD, + }; + }, +}; diff --git a/test/index.test.js b/test/index.test.js index 5b0e6be9..7cc45d33 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -67,6 +67,13 @@ test('AWS CodeBuild', t => { t.is(service, 'codebuild'); }); +test('AWS Amplify', t => { + const {isCi, service} = m({env: {AWS_APP_ID: 'd44r7xst5a1wzk'}}); + + t.is(isCi, true); + t.is(service, 'amplify'); +}); + test('Codefresh', t => { const {isCi, service} = m({env: {CF_BUILD_ID: '91011'}}); diff --git a/test/services/amplify.test.js b/test/services/amplify.test.js new file mode 100644 index 00000000..efc174ad --- /dev/null +++ b/test/services/amplify.test.js @@ -0,0 +1,26 @@ +const test = require('ava'); +const amplify = require('../../services/amplify'); + +const env = { + AWS_APP_ID: 'd44r7xst5a1wzk', + AWS_COMMIT_ID: '9cb0bda49d77cd39682a7a17cfe204bd59ac375f', + CODEBUILD_BUILD_ID: 'env-ci:40cc72d2-acd5-46f4-a86b-6a3dcd2a39a0', + CODEBUILD_BUILD_URL: + 'https://console.aws.amazon.com/codebuild/home?region=us-east-1#/builds/env-ci:40cc72d2-acd5-46f4-a86b-6a3dcd2a39a0/view/new', + AWS_BRANCH: 'master', + AWS_REGION: 'us-east-1', + PWD: '/codebuild/output/src604025264/src/github.com/', +}; + +test('Push', t => { + t.deepEqual(amplify.configuration({env}), { + name: 'AWS Amplify', + service: 'amplify', + commit: '9cb0bda49d77cd39682a7a17cfe204bd59ac375f', + build: 'env-ci:40cc72d2-acd5-46f4-a86b-6a3dcd2a39a0', + branch: 'master', + buildUrl: + 'https://console.aws.amazon.com/codebuild/home?region=us-east-1#/builds/env-ci:40cc72d2-acd5-46f4-a86b-6a3dcd2a39a0/view/new', + root: '/codebuild/output/src604025264/src/github.com/', + }); +});