Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
ci: drive app deploy from here
Browse files Browse the repository at this point in the history
So the app project does not need knowledge about the deployment
setup
  • Loading branch information
coderbyheart committed Jul 17, 2019
1 parent e2719b0 commit ef4002a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 14 deletions.
48 changes: 34 additions & 14 deletions cdk/BifravstContinuousDeploymentStack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class BifravstContinuousDeploymentStack extends CloudFormation.Stack {
'This project sets up the continuous deployment of the Bifravst app',
source: {
type: 'CODEPIPELINE',
buildSpec: 'continuous-deployment.yml',
buildSpec: 'continuous-deployment-app.yml',
},
serviceRole: codeBuildRole.roleArn,
artifacts: {
Expand All @@ -91,7 +91,7 @@ export class BifravstContinuousDeploymentStack extends CloudFormation.Stack {
image: 'aws/codebuild/standard:2.0',
environmentVariables: [
{
name: 'BIFRAVST_STACK_ID',
name: 'STACK_ID',
value: bifravstStackId,
},
],
Expand Down Expand Up @@ -142,7 +142,7 @@ export class BifravstContinuousDeploymentStack extends CloudFormation.Stack {
name: 'Source',
actions: [
{
name: 'SourceAction',
name: 'BifravstAWSSourceCode',
actionTypeId: {
category: 'Source',
owner: 'ThirdParty',
Expand All @@ -151,7 +151,7 @@ export class BifravstContinuousDeploymentStack extends CloudFormation.Stack {
},
outputArtifacts: [
{
name: 'SourceOutput',
name: 'BifravstAWS',
},
],
configuration: {
Expand All @@ -160,16 +160,15 @@ export class BifravstContinuousDeploymentStack extends CloudFormation.Stack {
Repo: repo,
OAuthToken: githubToken.stringValue,
},
runOrder: 1,
},
],
},
{
name: 'Deploy',
actions: [
{
name: 'DeployAction',
inputArtifacts: [{ name: 'SourceOutput' }],
name: 'DeployBifravst',
inputArtifacts: [{ name: 'BifravstAWS' }],
actionTypeId: {
category: 'Build',
owner: 'AWS',
Expand All @@ -179,7 +178,6 @@ export class BifravstContinuousDeploymentStack extends CloudFormation.Stack {
configuration: {
ProjectName: project.name,
},
runOrder: 1,
outputArtifacts: [
{
name: 'BuildId',
Expand Down Expand Up @@ -224,7 +222,27 @@ export class BifravstContinuousDeploymentStack extends CloudFormation.Stack {
name: 'Source',
actions: [
{
name: 'SourceAction',
name: 'BifravstAWSSourceCode',
actionTypeId: {
category: 'Source',
owner: 'ThirdParty',
version: '1',
provider: 'GitHub',
},
outputArtifacts: [
{
name: 'BifravstAWS',
},
],
configuration: {
Branch: branch,
Owner: owner,
Repo: repo,
OAuthToken: githubToken.stringValue,
},
},
{
name: 'BifravstAppSourceCode',
actionTypeId: {
category: 'Source',
owner: 'ThirdParty',
Expand All @@ -233,7 +251,7 @@ export class BifravstContinuousDeploymentStack extends CloudFormation.Stack {
},
outputArtifacts: [
{
name: 'SourceOutput',
name: 'BifravstApp',
},
],
configuration: {
Expand All @@ -242,16 +260,18 @@ export class BifravstContinuousDeploymentStack extends CloudFormation.Stack {
Repo: app.repo,
OAuthToken: githubToken.stringValue,
},
runOrder: 1,
},
],
},
{
name: 'Deploy',
actions: [
{
name: 'DeployAction',
inputArtifacts: [{ name: 'SourceOutput' }],
name: 'DeployBifravstApp',
inputArtifacts: [
{ name: 'BifravstAWS' },
{ name: 'BifravstApp' },
],
actionTypeId: {
category: 'Build',
owner: 'AWS',
Expand All @@ -260,8 +280,8 @@ export class BifravstContinuousDeploymentStack extends CloudFormation.Stack {
},
configuration: {
ProjectName: appProject.name,
PrimarySource: 'BifravstAWS',
},
runOrder: 1,
outputArtifacts: [
{
name: 'BuildId',
Expand Down
16 changes: 16 additions & 0 deletions continuous-deployment-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 0.2
phases:
install:
runtime-versions:
nodejs: 10
commands:
- npm install -g npm@
- npm ci --no-audit
- npx tsc
build:
commands:
- node dist/scripts/print-react-app-configuration.js > $CODEBUILD_SRC_DIR_BifravstApp/.env.production.local
- cat $CODEBUILD_SRC_DIR_BifravstApp/.env.production.local
- export $(cat $CODEBUILD_SRC_DIR_BifravstApp/.env.production.local | xargs)
- cd $CODEBUILD_SRC_DIR_BifravstApp/; npm ci --no-audit; npm run build;
- aws s3 cp $CODEBUILD_SRC_DIR_BifravstApp/build s3://$REACT_APP_WEBSITE_BUCKET_NAME --recursive --metadata-directive REPLACE --cache-control 'public,max-age=600' --expires ''

0 comments on commit ef4002a

Please sign in to comment.