Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IaC and CI/CD workflows (issue #7) #26

Merged
merged 58 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
6b42032
chore: initial commit
as1729 Nov 3, 2023
ef8d91f
chore: add basic models
as1729 Nov 15, 2023
a1856b3
v3.6.3
TylerHendrickson Nov 17, 2023
fa41860
First pass at standing up terraform infra
TylerHendrickson Nov 29, 2023
ceb0191
Terraform fixes
TylerHendrickson Nov 29, 2023
b4e3089
More tf fixes
TylerHendrickson Nov 29, 2023
b18cc12
Add CI workflow for PRs
TylerHendrickson Nov 29, 2023
74108d4
Add static analysis workflows
TylerHendrickson Nov 29, 2023
6384bea
Configure TF defaults for staging
TylerHendrickson Dec 1, 2023
5d531a3
Initial TF version lock
TylerHendrickson Dec 1, 2023
1a479bf
Configure tflint
TylerHendrickson Dec 1, 2023
9d2f1cc
Configure jest coverage reporters
TylerHendrickson Dec 1, 2023
6b3aad9
Tweak graphql lambda timeout
TylerHendrickson Dec 1, 2023
01f2861
Ignore terraform cache
TylerHendrickson Dec 1, 2023
bb2d268
Update dotenv defaults
TylerHendrickson Dec 1, 2023
f44709c
Allow $API_URL to override web.apiUrl default
TylerHendrickson Dec 1, 2023
f66f7b3
Adjust redwood config
TylerHendrickson Dec 1, 2023
70b2f38
Node v18.x
TylerHendrickson Dec 1, 2023
a571186
Yarn 3.7.0
TylerHendrickson Dec 1, 2023
f18bdc9
VSCode defaults
TylerHendrickson Dec 1, 2023
61e3113
Track yarn settings and state
TylerHendrickson Dec 1, 2023
e502e48
Initial .gitattributes
TylerHendrickson Dec 1, 2023
edee0f4
Auto-generated .dockerignore
TylerHendrickson Dec 1, 2023
a028852
Version bumps
TylerHendrickson Dec 1, 2023
03e2aac
Add interactive-tools yarn plugin
TylerHendrickson Dec 1, 2023
e637b1b
Make prisma work in different hosting environments
TylerHendrickson Dec 1, 2023
e4785c5
Add Dockerfile and docker-compose for dev
TylerHendrickson Dec 1, 2023
ece8751
Populate .env during web build
TylerHendrickson Dec 1, 2023
442674a
Ignore .redwood
TylerHendrickson Dec 1, 2023
3e19f08
Configure staging deployment workflows
TylerHendrickson Dec 1, 2023
78a04b4
Configure release management workflows
TylerHendrickson Dec 1, 2023
fad8b46
Add datadog service catalog metadata
TylerHendrickson Dec 1, 2023
9ae0c54
Fix test config
TylerHendrickson Dec 1, 2023
5377c66
Fix typo
TylerHendrickson Dec 1, 2023
2359c57
Add the standard .md assets
TylerHendrickson Dec 1, 2023
3d30212
Change CI trigger for testing
TylerHendrickson Dec 1, 2023
1f96221
Fix some vulnerable packages
TylerHendrickson Dec 1, 2023
12317d4
Fix build path typo
TylerHendrickson Dec 1, 2023
739a713
Fix yarn install issue for eslint
TylerHendrickson Dec 1, 2023
e04ba01
Resolve more package vulnerabilities
TylerHendrickson Dec 1, 2023
79e0428
Resolve more package vulnerabilities
TylerHendrickson Dec 1, 2023
dcb2123
Fix QA report
TylerHendrickson Dec 1, 2023
5625999
Addressing vulnerable packages / fighting with yarn
TylerHendrickson Dec 1, 2023
a5431f8
Only fail review for vulnerable runtime deps
TylerHendrickson Dec 1, 2023
63cf8f9
Fix comment formatting
TylerHendrickson Dec 1, 2023
3ad9bdb
Fix invalid TF module reference
TylerHendrickson Dec 1, 2023
f476fdf
Remove unused deps and regenerate yarn.lock from scratch
TylerHendrickson Dec 1, 2023
fc5471b
Make TF namespacing consistent
TylerHendrickson Dec 1, 2023
5cd526f
Fix deprecated cloudposse/iam-policy/aws module arguments
TylerHendrickson Dec 1, 2023
70cfd7e
Version bump
TylerHendrickson Dec 5, 2023
3099eb2
Bump actions/dependency-review-action to v3.1.4
TylerHendrickson Dec 5, 2023
13b8590
Add dependency review config
TylerHendrickson Dec 5, 2023
289887e
Syntax fix
TylerHendrickson Dec 5, 2023
e50da9e
Merge branch 'main' into 7-deployment-infra
TylerHendrickson Dec 5, 2023
a6b609c
Add CODEOWNERS
TylerHendrickson Dec 5, 2023
944d12e
Test triggers for release-drafter PR workflows
TylerHendrickson Dec 5, 2023
e6962aa
Remove test triggers for release-drafter PR workflows
TylerHendrickson Dec 5, 2023
aaef09a
HTML fix
TylerHendrickson Dec 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
**/node_modules
**/dist
.redwood

.env

README.md
LICENSE

.git
.gitignore

.vscode
.editorconfig

Dockerfile
docker-compose*
.dockerignore
28 changes: 28 additions & 0 deletions .env.defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# These environment variables will be used by default if you do not create any
# yourself in .env. This file should be safe to check into your version control
# system. Any custom values should go in .env and .env should *not* be checked
# into version control.

# schema.prisma defaults
DATABASE_URL=file:./dev.db
DATABASE_URL_IAM_AUTH=false
DATABASE_SECRET_SOURCE=''
DATABASE_SECRET_PARAMETER_PATH=''

# location of the test database for api service scenarios (defaults to ./.redwood/test.db if not set)
# TEST_DATABASE_URL=file:./.redwood/test.db

# disables Prisma CLI update notifier
PRISMA_HIDE_UPDATE_MESSAGE=true

# Option to override the current environment's default api-side log level
# See: https://redwoodjs.com/docs/logger for level options, defaults to "trace" otherwise.
# Most applications want "debug" or "info" during dev, "trace" when you have issues and "warn" in production.
# Ordered by how verbose they are: trace | debug | info | warn | error | silent
LOG_LEVEL=debug

# AWS environment defaults
AWS_REGION=us-west-2
AWS_DEFAULT_REGION=us-west-2
AWS_ACCESS_KEY_ID=test
AWS_SECRET_ACCESS_KEY=test
21 changes: 21 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Consider all files text by default; enforce unix line endings
* text eol=lf

# Treat these files as binary so git doesn't show massive diffs
/.yarn/releases/** binary
/.yarn/plugins/** binary

# Windows-specific files that need windows-style endings to work
*.bat text eol=crlf

# Files that are actually binary
*.data binary
*.eot binary
*.gif binary
*.ico binary
*.jar binary
*.jpg binary
*.png binary
*.ttf binary
*.woff binary
*.woff2 binary
14 changes: 14 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Require admin approval for GitHub settings and workflow modifications
/.github/ @usdigitalresponse/grants-admins

# Require admin approval for Terraform IAC modifications
/terraform/ @usdigitalresponse/grants-admins

# Require admin approval when Postgres root CA bundle is modified
/api/db/rds-combined-ca-bundle.pem @usdigitalresponse/grants-admins

# Require admin approval for special doc modifications
README.md @usdigitalresponse/grants-admins
LICENSE @usdigitalresponse/grants-admins
CODE_OF_CONDUCT.md @usdigitalresponse/grants-admins
CONTRIBUTING.md @usdigitalresponse/grants-admins
14 changes: 14 additions & 0 deletions .github/dependency-review-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Configuration for https://github.com/actions/dependency-review-action
# Used in .github/workflows/code-scanning.yml

fail_on_scopes:
- runtime

# All allowances should provide details, including rationale.
allow_ghsas:
# Only used during build / development:
- GHSA-pfrx-2q88-qq97 # Got allows a redirect to a UNIX socket (moderate severity)
- GHSA-9c47-m6qq-7p4h # Prototype Pollution in JSON5 via Parse Method (high severity)
- GHSA-ww39-953v-wcq6 # glob-parent vulnerable to Regular Expression Denial of Service in enclosure regex (high severity)
# Last remaining usage of vulnerable semver (7.0.0) is used for dev update notifications:
- GHSA-c2qf-rxjj-qqgw # semver vulnerable to Regular Expression Denial of Service (moderate severity)
53 changes: 53 additions & 0 deletions .github/next_release_version.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#! /bin/bash

# Defaults
next_version_release_year=$(TZ='UTC' date '+%Y')
next_version_release_number=1

if [[ $1 == 'test' ]]; then
echo 'Running tests...' >&2
dotest() {
result=$(bash $0 "release/${1}" 2> /dev/null | tail -n 1)
expect="${2}"
if [[ $result != $expect ]]; then
printf "Test failed:\n Expected: $expect\n Received: $result\n" >&2
exit 1
fi
}
dotest 'release/1234.987' "$next_version_release_year.1"
dotest 'release/0.0' "$next_version_release_year.1"
dotest 'release/0' "$next_version_release_year.1"
dotest 'sometag' "$next_version_release_year.1"
dotest "release/$next_version_release_year.1" "$next_version_release_year.2"
dotest "release/$next_version_release_year.19" "$next_version_release_year.20"
dotest "release/$next_version_release_year.399" "$next_version_release_year.400"
echo 'Tests complete' >&2
exit 0
fi

if [[ -z $1 ]]; then
# Ensure tag history is available
git fetch --prune --unshallow
tag=$(git describe --tags --match='release/[0-9][0-9][0-9][0-9].[0-9]*' refs/heads/main)
else
tag=$1
fi

regex='release\/([0-9]{4})\.([0-9]+)'
if [[ $tag =~ $regex ]]; then
echo "Found tag for previous release: $tag" >&2
prev_version_release_number="${BASH_REMATCH[2]}"
echo "Previous version number: $prev_version_release_number" >&2
if [[ $next_version_release_year == "${BASH_REMATCH[1]}" ]]; then
((next_version_release_number=prev_version_release_number+1))
else
echo "Ignoring previous version number because it pertains to a different year" >&2
fi
else
echo "Could not locate a previous release version" >&2
fi

next_version="$next_version_release_year.$next_version_release_number"
echo "Next version: $next_version" >&2
# Output result to stdout
printf "$next_version"
120 changes: 120 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/release-drafter/release-drafter/master/schema.json
name-template: 'v$RESOLVED_VERSION'
tag-template: 'release/$RESOLVED_VERSION'
tag-prefix: 'release/'
version-template: '2023.$MINOR'
version-resolver:
default: minor
prerelease: true
categories:
- title: 🚀 New features and enhancements
collapse-after: 10
labels:
- enhancement
- title: 🐛 Bug fixes
collapse-after: 10
labels:
- bug
- title: 📖 Documentation improvements
collapse-after: 10
labels:
- documentation
- title: 🔧 Dependency updates
collapse-after: 3
labels:
- dependencies
- title: Other changes
labels:
- '*'
category-template: '### $TITLE'
exclude-labels:
- skip-changelog
exclude-contributors:
- dependabot
- 'dependabot[bot]'
- step-security-bot
autolabeler:
- label: javascript
files:
- '**/*.js'
- '**/*.ts'
- '**/package.json'
- 'api/**'
- 'web/**'
- '**/yarn.lock'
- '**/.npmrc'
- '**/.nvmrc'
- '**/.nycrc'
- '**/eslintrc.js'
- '**/.browserslistrc'
- label: database
files:
- 'api/db/**'
- label: terraform
files:
- 'terraform/**'
- label: infra
files:
- 'terraform/**'
- 'Dockerfile'
- '**/docker-compose.yml'
- '**/docker-compose.yaml'
- '**/docker-compose.*.yml'
- '**/docker-compose.*.yaml'
- 'localstack/**'
- label: dependencies
files:
- '**/yarn.lock'
- '**/.terraform.lock.hcl'
branch:
- '/^dependabot\/.+$/i'
- label: documentation
files:
- README
- '**/doc/**'
- '**/docs/**'
- '**/*.md'
- .adr-dir
branch:
- '/^docs?\/.+$/'
- label: bug
branch:
- '/^fix\/.+$/i'
- '/^bug\/.+$/i'
title:
- '/\bfix(es)?\b/i'
- '/\bbug\b/i'
- '/\brevert(s)?\b/i'
- label: enhancement
branch:
- '/^feat(ures?)?\/.+$/i'
- '/^enhance(s|ments?)?\/.+$/i'
title:
- '/\b(?<!^chores?\b.*)feat(ures?)?\b/i'
- '/\b(?<!^chores?\b.*)enhance(s|ment)?\b/i'
- label: github
files:
- '.github/**'
- '**/.gitignore'
- '**/.gitattributes'
- '**/CODEOWNERS'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&'
no-contributors-template: >-
'*All changes in this release were crafted by robots (and reviewed by humans).*'
template: |
## 📚 Summary

The releaser should provide a high-level summary here (or remove this section).

## 🛠️ Changes

$CHANGES

## 🤝 Contributors

We would like to thank the following people who made this release possible:

$CONTRIBUTORS

## Deployment History
69 changes: 69 additions & 0 deletions .github/workflows/aws-auth.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Configure AWS Credentials

on:
workflow_call:
inputs:
aws-region:
type: string
required: true
secrets:
role-to-assume:
required: true
gpg-passphrase:
required: true
outputs:
aws-access-key-id:
value: ${{ jobs.oidc-auth.outputs.aws-access-key-id }}
aws-secret-access-key:
value: ${{ jobs.oidc-auth.outputs.aws-secret-access-key }}
aws-session-token:
value: ${{ jobs.oidc-auth.outputs.aws-session-token }}

permissions:
contents: read
id-token: write

jobs:
oidc-auth:
name: OIDC Auth
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
outputs:
aws-access-key-id: ${{ steps.encrypt-aws-access-key-id.outputs.out }}
aws-secret-access-key: ${{ steps.encrypt-aws-secret-access-key.outputs.out }}
aws-session-token: ${{ steps.encrypt-aws-session-token.outputs.out }}
steps:
- uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
sts.us-west-2.amazonaws.com:443
- id: auth
uses: aws-actions/configure-aws-credentials@010d0da01d0b5a38af31e9c3470dbfdabdecca3a # v4.0.1
with:
aws-region: us-west-2
role-to-assume: "${{ secrets.role-to-assume }}"
- name: Encrypt aws-access-key-id
id: encrypt-aws-access-key-id
run: |
encrypted=$(gpg --batch --yes --passphrase "$GPG_PASSPHRASE" -c --cipher-algo AES256 -o - <(echo "$AWS_ACCESS_KEY_ID") | base64 -w0)
echo "out=$encrypted" >> $GITHUB_OUTPUT
env:
GPG_PASSPHRASE: ${{ secrets.gpg-passphrase }}
- name: Encrypt aws-secret-access-key
id: encrypt-aws-secret-access-key
run: |
encrypted=$(gpg --batch --yes --passphrase "$GPG_PASSPHRASE" -c --cipher-algo AES256 -o - <(echo "$AWS_SECRET_ACCESS_KEY") | base64 -w0)
echo "out=$encrypted" >> $GITHUB_OUTPUT
env:
GPG_PASSPHRASE: ${{ secrets.gpg-passphrase }}
- name: Encrypt aws-session-token
id: encrypt-aws-session-token
run: |
encrypted=$(gpg --batch --yes --passphrase "$GPG_PASSPHRASE" -c --cipher-algo AES256 -o - <(echo "$AWS_SESSION_TOKEN") | base64 -w0)
echo "out=$encrypted" >> $GITHUB_OUTPUT
env:
GPG_PASSPHRASE: ${{ secrets.gpg-passphrase }}
Loading
Loading