|
| 1 | +name: Deploy |
| 2 | + |
| 3 | +inputs: |
| 4 | + env_aws_secret_name: |
| 5 | + required: false |
| 6 | + type: string |
| 7 | + default: '' |
| 8 | + dir: |
| 9 | + required: false |
| 10 | + type: string |
| 11 | + default: "." |
| 12 | + script_path: |
| 13 | + required: true |
| 14 | + type: string |
| 15 | + default: '' |
| 16 | + skip_deploy: |
| 17 | + required: false |
| 18 | + type: string |
| 19 | + default: 'false' |
| 20 | + |
| 21 | +runs: |
| 22 | + using: "composite" |
| 23 | + steps: |
| 24 | + - name: Install node and related deps |
| 25 | + uses: actions/setup-node@v4 |
| 26 | + with: |
| 27 | + node-version: 20 |
| 28 | + |
| 29 | + - uses: actions/cache@v3 |
| 30 | + with: |
| 31 | + path: ~/.npm |
| 32 | + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} |
| 33 | + |
| 34 | + - name: Install AWS CDK |
| 35 | + shell: bash |
| 36 | + run: npm install -g aws-cdk@2 |
| 37 | + |
| 38 | + - name: Install uv |
| 39 | + uses: astral-sh/setup-uv@v3 |
| 40 | + with: |
| 41 | + version: "0.5.*" |
| 42 | + |
| 43 | + - name: Set up Python |
| 44 | + uses: actions/setup-python@v5 |
| 45 | + with: |
| 46 | + python-version: '3.12' |
| 47 | + |
| 48 | + - name: Install dependencies |
| 49 | + shell: bash |
| 50 | + working-directory: ${{ inputs.dir }} |
| 51 | + run: | |
| 52 | + uv sync --only-group deployment |
| 53 | + uv run npm install |
| 54 | + uv pip install boto3 # for the generate_env_file.py script |
| 55 | +
|
| 56 | + - name: Get relevant environment configuration from aws secrets |
| 57 | + if: inputs.env_aws_secret_name != '' |
| 58 | + shell: bash |
| 59 | + env: |
| 60 | + AWS_DEFAULT_REGION: us-west-2 |
| 61 | + run: python ${{ inputs.script_path }} --secret-id ${{ inputs.env_aws_secret_name }} --env-file ${{ inputs.dir }}/.env |
| 62 | + |
| 63 | + - name: CDK Synth |
| 64 | + shell: bash |
| 65 | + working-directory: ${{ inputs.dir }} |
| 66 | + run: uv run --only-group deployment npm run cdk -- synth |
| 67 | + |
| 68 | + - name: Check Asset Sizes |
| 69 | + shell: bash |
| 70 | + working-directory: ${{ inputs.dir }} |
| 71 | + run: | |
| 72 | + MAX_SIZE_BYTES=262144000 # 262 MB in bytes |
| 73 | + for dir in cdk.out/asset.*; do |
| 74 | + if [ -d "$dir" ]; then |
| 75 | + size=$(du -sb "$dir" | cut -f1) |
| 76 | + if [ "$size" -gt $MAX_SIZE_BYTES ]; then |
| 77 | + echo "Directory $dir exceeds 262 MB with size $size bytes (max: $MAX_SIZE_BYTES bytes)." |
| 78 | + exit 1 |
| 79 | + fi |
| 80 | + echo "Asset directory $dir size: $size bytes" |
| 81 | + fi |
| 82 | + done |
| 83 | + echo "All asset directories are within size limits." |
| 84 | +
|
| 85 | + - name: Deploy Test |
| 86 | + if: ${{ inputs.skip_deploy == 'false' }} |
| 87 | + id: deploy_titiler_cmr_stack |
| 88 | + working-directory: ${{ inputs.dir }} |
| 89 | + run: uv run cdk deploy --all --require-approval never --outputs-file ${HOME}/cdk-outputs.json |
| 90 | + shell: bash |
| 91 | + env: |
| 92 | + TITILER_CMR_ADDITIONAL_ENV: '{"TITILER_CMR_S3_AUTH_STRATEGY":"iam"}' |
0 commit comments