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

Initial PR #1

Merged
merged 27 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
111 changes: 108 additions & 3 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ on:
workflow_dispatch:
hrodmn marked this conversation as resolved.
Show resolved Hide resolved
inputs:
deployment_environment:
description: 'environment'
description: 'environment (either dev or test)'
required: true
api_version:
description: 'federated collection discovery API version'
description: 'federated collection discovery API version - must be in this [list of tags](https://github.com/developmentseed/federated-collection-discovery/tags)'
required: true
default: '0.1.0'
default: '0.1.1'

jobs:
build_and_deploy:
Expand All @@ -23,5 +23,110 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Checkout client repository
uses: actions/checkout@v4
with:
repository: developmentseed/federated-collection-discovery
path: client_app
sparse-checkout: src/client
ref: "${{ github.event.inputs.api_version }}"

- name: Set up node
uses: actions/setup-node@v4
with:
node-version: 22

- name: Cache Node.js dependencies
uses: actions/cache@v4
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
node-modules-${{ runner.os }}-

- name: Cache Yarn dependencies
uses: actions/cache@v4
with:
path: |
client_app/src/client/node_modules
client_app/src/client/.yarn
key: yarn-cache-${{ runner.os }}-${{ hashFiles('client_app/src/client/yarn.lock') }}
restore-keys: |
yarn-cache-${{ runner.os }}-


- name: Install Yarn
run: npm install -g yarn

- name: Install Poetry
uses: Gr1N/setup-poetry@v9
with:
poetry-version: "1.8.0"

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: poetry
cache-dependency-path: poetry.lock

- name: Assume Github OIDC role
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-west-2
role-to-assume: ${{ vars.DEPLOY_ROLE }}
role-session-name: federated-collection-discovery-${{ github.event.inputs.deployment_environment }}-deploy

- name: Install deployment dependencies
run: |
npm install
poetry install
cd client_app/src/client
yarn install

- name: Run CDK deploy
env:
STAGE: "${{ github.event.inputs.deployment_environment }}"
API_VERSION: "${{ github.event.inputs.api_version }}"
API_CERTIFICATE_ARN: "${{ vars.API_CERTIFICATE_ARN }}"
API_DOMAIN_NAME: "${{ vars.API_DOMAIN_NAME }}"
CLIENT_CERTIFICATE_ARN: "${{ vars.CLIENT_CERTIFICATE_ARN }}"
CLIENT_DOMAIN_NAME: "${{ vars.CLIENT_DOMAIN_NAME }}"
STAC_API_URLS: ${{ vars.STAC_API_URLS }}
run: |
start_time=$(date +%s)
poetry run npx cdk deploy --all --require-approval never --outputs-file cdk-output.json
status=$?
end_time=$(date +%s)
duration=$((end_time - start_time))
echo "success=${status}" >> $GITHUB_ENV
echo "duration=${duration}" >> $GITHUB_ENV
if [ $status -eq 0 ]; then
echo "CDK deploy successful."
else
echo "CDK deploy failed." >&2
exit 1
fi
export STACK_NAME=$(jq -r 'keys_unsorted[0]' cdk-output.json)
export REACT_APP_API_URL=$(jq -r --arg stack_name "$STACK_NAME" '.[$stack_name].ApiEndpoint' cdk-output.json)
echo "REACT_APP_API_URL=$REACT_APP_API_URL" >> $GITHUB_ENV
export BUCKET_NAME=$(jq -r --arg stack_name "$STACK_NAME" '.[$stack_name].ClientBucketName' cdk-output.json)
echo "BUCKET_NAME=$BUCKET_NAME" >> $GITHUB_ENV
export DISTRIBUTION_ID=$(jq -r --arg stack_name "$STACK_NAME" '.[$stack_name].CloudFrontId' cdk-output.json)
echo "DISTRIBUTION_ID=$DISTRIBUTION_ID" >> $GITHUB_ENV

- name: Build and deploy client app
working-directory: client_app/src/client
run: |
yarn build
hrodmn marked this conversation as resolved.
Show resolved Hide resolved
aws s3 sync ./build s3://${BUCKET_NAME}
# invalidate existing index.html to refresh the site
aws cloudfront create-invalidation --distribution-id ${DISTRIBUTION_ID} --paths "/*"

- name: Upload cdk-output.json
uses: actions/upload-artifact@v4
with:
name: cdk-output.json

path: cdk-output.json
215 changes: 215 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
# Created by https://www.toptal.com/developers/gitignore/api/node
# Edit at https://www.toptal.com/developers/gitignore?templates=node

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

### Node Patch ###
# Serverless Webpack directories
.webpack/

# Optional stylelint cache

# SvelteKit build / generate output
.svelte-kit

# End of https://www.toptal.com/developers/gitignore/api/node
# Created by https://www.toptal.com/developers/gitignore/api/macos
# Edit at https://www.toptal.com/developers/gitignore?templates=macos

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

# End of https://www.toptal.com/developers/gitignore/api/macos
# Created by https://www.toptal.com/developers/gitignore/api/linux
# Edit at https://www.toptal.com/developers/gitignore?templates=linux

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

# End of https://www.toptal.com/developers/gitignore/api/linux

# virtual environments
env
venv
.venv

# direnv
.envrc

# CDK
.env-cdk
cdk.out/
cdk-output.json

# client app
client_app/
Expand Down
36 changes: 36 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Configuration file for pre-commit (https://pre-commit.com/).
# Please run `pre-commit run --all-files` when adding or changing entries.

repos:
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.13.0
hooks:
- id: markdownlint-cli2
language_version: "18.17.1"
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
# args: [--ignore-words=.codespellignore]
types_or: [jupyter, markdown, python, shell]
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.1
hooks:
- id: mypy
additional_dependencies:
- pydantic~=2.8.2
- pydantic-settings~=2.4.0
- aws-cdk-lib~=2.151.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.7
hooks:
- id: ruff
- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
args: [--max-line-length=88]
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.PHONY: install
install:
npm install
npm install -g yarn
poetry install
pre-commit install

.PHONY: deploy
deploy:
poetry run npx cdk deploy --all --require-approval never --outputs-file cdk-output.json


.PHONY: destroy
destroy:
poetry run npx cdk destroy --all
Loading