Skip to content

Commit

Permalink
Merge branch 'qa' into prod
Browse files Browse the repository at this point in the history
  • Loading branch information
ScriptSmith committed Oct 11, 2023
2 parents 2ac3db5 + b43dc85 commit 77709e3
Show file tree
Hide file tree
Showing 41 changed files with 18,121 additions and 7,979 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Deploy CDK Stack
on:
push:
branches:
- dev
- qa
- prod
jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ github.ref_name }}
permissions:
actions: write
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- name: Create frontend output dir
run: mkdir -p frontend/out
- name: Setup api
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: api
- name: Install api dependencies
working-directory: api
run: npm install
- name: Setup deployment
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: deployment
- name: Install CDK
run: npm install -g aws-cdk
- name: Install deployment dependencies
working-directory: deployment
run: npm install
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ap-southeast-2
role-to-assume: ${{ secrets.API_ROLE_ARN }}
role-duration-seconds: 1800
output-credentials: true
mask-aws-account-id: true
- name: Deploy base stack
working-directory: deployment
run: cdk deploy TranscriptionStack
- name: Save FrontEndEnvironment to file
working-directory: frontend
run: aws cloudformation describe-stacks --stack-name ${{ vars.ENVIRONMENT }}-transcription --query "Stacks[0].Outputs[?OutputKey=='FrontEndEnvironment'].OutputValue" --output text > .env.production
- name: Setup frontend
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: frontend
- name: Install frontend dependencies
working-directory: frontend
run: yarn install
- name: Build frontend
working-directory: frontend
run: yarn build
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ap-southeast-2
role-to-assume: ${{ secrets.FRONTEND_ROLE_ARN }}
role-duration-seconds: 1800
output-credentials: true
mask-aws-account-id: true
- name: Deploy frontend stack
working-directory: deployment
run: cdk deploy TranscriptionFrontEndStack
18 changes: 0 additions & 18 deletions INSTRUCTIONS.md

This file was deleted.

90 changes: 75 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
![homepage](images/homepage.png)
![transcription](images/transcription.png)

[Custom deployment instructions](INSTRUCTIONS.md)

## Linting and Formatting

### Frontend
Expand Down Expand Up @@ -34,27 +32,89 @@ git config blame.ignoreRevsFile .git-blame-ignore-revs
## Manual deployment instructions

```
export ENV=dev # or qa, prod
cd api
npm install
```

```
cd frontend
yarn install
mkdir -p out
```

export STACK_NAME=$ENV-transcription
export LAMBDA_BUCKET_NAME=qut-lambda-code-ap-southeast-2-dev
export S3_PREFIX=dev-transcription
```
cd deployment
npm install
```

### In root
### *Optional: Create GitHub deployment stack*

```
sam build
sam deploy --s3-bucket $LAMBDA_BUCKET_NAME --s3-prefix $STACK_NAME --stack-name $STACK_NAME --capabilities CAPABILITY_IAM --profile account-role
aws cloudformation describe-stacks --stack-name $STACK_NAME --query "Stacks[0].Outputs[?OutputKey=='FrontEndEnvironment'].OutputValue" --output text --profile account-role | sed '/^[[:space:]]*$/d' > ./frontend/.env.production
export GITHUB_REF_NAME=dev
export GITHUB_FILTERS="environment:dev"
cdk deploy TranscriptionGitHubStack
cdk deploy TranscriptionFrontEndGitHubStack
```

### In frontend
### *Optional: Assume the GitHub role locally*


`~/.aws/config`:

```
[profile qut-dev]
region = ap-southeast-2
[profile qut-dev-github]
role_arn = <TranscriptionGitHubStack.deployRoleArn>
source_profile = qut-dev
region = ap-southeast-2
[profile qut-dev-github-frontend]
role_arn = <TranscriptionFrontEndGitHubStack.deployRoleArn>
source_profile = qut-dev
region = ap-southeast-2
```

Deploy the stacks with the GitHub role:

```
AWS_PROFILE=qut-dev-github cdk deploy TranscriptionStack
AWS_PROFILE=qut-dev-github-frontend cdk deploy TranscriptionFrontEndStack
```

### Deploy base stack

Also builds the lambda functions

```
cdk deploy TranscriptionStack
```

### Build the frontend

```
export STACK_NAME=dev-transcription
aws cloudformation describe-stacks --stack-name $STACK_NAME --query "Stacks[0].Outputs[?OutputKey=='FrontEndEnvironment'].OutputValue" --output text > ../frontend/.env.production
```

From the top-level `frontend` directory:

```
yarn install
yarn build
export $(aws cloudformation describe-stacks --stack-name $ENV-transcription --region ap-southeast-2 --query "Stacks[0].Outputs[?OutputKey=='DistributionEnvironment'].OutputValue" --output text --profile account-role | sed '/^[[:space:]]*$/d' | xargs)
aws s3 sync out $DISTRIBUTION_BUCKET --profile account-role
aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths "/*" --profile account-role
```

### Deploy frontend stack

```
cdk deploy FrontEndStack
```

## Local frontend development

```
cd frontend
export STACK_NAME=dev-transcription
aws cloudformation describe-stacks --stack-name $STACK_NAME --query "Stacks[0].Outputs[?OutputKey=='FrontEndEnvironment'].OutputValue" --output text > .env.local
yarn dev
```
1 change: 0 additions & 1 deletion api/.prettierrc

This file was deleted.

Loading

0 comments on commit 77709e3

Please sign in to comment.