Merge pull request #257 from NASA-IMPACT/mcp #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: mcp dev deployment | |
on: | |
push: | |
branches: [dev] | |
workflow_dispatch: | |
env: | |
AWS_DEFAULT_REGION: us-west-2 | |
# See https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services#updating-your-github-actions-workflow | |
permissions: | |
id-token: write # required for requesting the JWT | |
contents: read # required for actions/checkout | |
jobs: | |
unit-tests: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
python: [3.8] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Install Tox | |
run: pip install tox | |
- name: Run Tox test environment | |
# Run tox using the version of Python in `PATH` | |
run: tox -e py | |
mcp-dev-deployment: | |
strategy: | |
matrix: | |
python: [3.8] | |
runs-on: ubuntu-20.04 | |
needs: [unit-tests] | |
environment: | |
name: mcp-dev | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Install tox | |
run: pip install tox | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v3 | |
with: | |
role-to-assume: ${{ vars.AWS_ROLE_TO_ASSUME_ARN }} | |
role-session-name: ${{ github.actor }} | |
aws-region: us-west-2 | |
- name: Convert secrets to environment variables | |
env: | |
SECRETS_JSON: ${{ toJson(secrets) }} | |
run: | | |
while read -rd $'' line; do | |
echo "$line" >> $GITHUB_ENV | |
done < <( | |
jq -r <<<"$SECRETS_JSON" 'to_entries|map("\(.key)=\(.value)\u0000")[]' | |
) | |
- name: Convert vars to environment variables | |
env: | |
VARS_JSON: ${{ toJson(vars) }} | |
run: | | |
while read -rd $'' line; do | |
echo "$line" >> $GITHUB_ENV | |
done < <( | |
jq -r <<<"$VARS_JSON" 'to_entries|map("\(.key)=\(.value)\u0000")[]' | |
) | |
- name: Deploy with tox | |
run: | | |
# NOTICES | |
# | |
# 19836 AWS CDK v1 End-of-Support June 1, 2023 | |
# | |
# Overview: AWS CDK v1 is currently in maintenance mode. Support for AWS | |
# CDK v1 will end entirely on June 1, 2023. Migrate to AWS CDK | |
# v2 to continue to get the latest features and fixes! | |
# | |
# Affected versions: framework: 1.*, cli: 1.* | |
# | |
# More information at: https://github.com/aws/aws-cdk/issues/19836 | |
# | |
# | |
# If you don’t want to see a notice anymore, use "cdk acknowledge <id>". | |
# For example, "cdk acknowledge 19836". | |
cdk acknowledge 19836 | |
tox -v -e dev -r -- deploy --require-approval never | |
- name: Run DB setup | |
run: | | |
setupdb=$(aws cloudformation describe-stacks \ | |
--stack-name $HLS_STACKNAME \ | |
--query "Stacks[0].Outputs[?OutputKey=='setupdbexport'].OutputValue" \ | |
--output=text | |
) | |
aws lambda invoke --function-name=$setupdb response.json |