[NDR-318] Build a sandbox and deploy from the cli #3958
This file contains hidden or 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: "CI Lambdas - CI Feature to Main" | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "lambdas/**" | |
| - "Makefile" | |
| - ".github/**" | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - ".github/**" | |
| - "lambdas/**" | |
| - "Makefile" | |
| workflow_call: | |
| secrets: | |
| AWS_ASSUME_ROLE: | |
| required: true | |
| permissions: | |
| pull-requests: write | |
| id-token: write # This is required for requesting the JWT | |
| contents: read # This is required for actions/checkout | |
| jobs: | |
| check_packages: | |
| if: github.event_name == 'pull_request' | |
| uses: ./.github/workflows/base-lambdas-check-packages.yml | |
| with: | |
| environment: development | |
| python_version: 3.11 | |
| build_branch: ${{github.event.pull_request.head.ref}} | |
| run_tests: | |
| uses: ./.github/workflows/base-lambdas-reusable-test.yml | |
| with: | |
| python_version: 3.11 | |
| build_branch: ${{github.event.pull_request.head.ref}} | |
| publish_all_lambda_layers: | |
| name: Publish all Lambda Layers | |
| needs: ["run_tests"] | |
| uses: ./.github/workflows/base-lambda-layer-reusable-publish-all.yml | |
| if: | | |
| (github.ref == 'refs/heads/main') | |
| with: | |
| environment: development | |
| python_version: "3.11" | |
| build_branch: ${{github.event.pull_request.head.ref}} | |
| sandbox: ndr-dev | |
| secrets: | |
| AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }} | |
| deploy_all_lambdas: | |
| uses: ./.github/workflows/base-lambdas-reusable-deploy-all.yml | |
| needs: ["run_tests", "publish_all_lambda_layers"] | |
| if: | | |
| (github.ref == 'refs/heads/main') | |
| with: | |
| environment: development | |
| python_version: "3.11" | |
| build_branch: ${{github.event.pull_request.head.ref}} | |
| sandbox: ndr-dev | |
| mock_login_enabled: true | |
| secrets: | |
| AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }} | |
| deploy_data_collection: | |
| name: Deploy ODS Data Collection | |
| needs: ["run_tests"] | |
| uses: ./.github/workflows/base-data-collection.yml | |
| if: github.ref == 'refs/heads/main' | |
| with: | |
| build_branch: ${{ github.event.pull_request.head.ref }} | |
| environment: development | |
| sandbox: ndr-dev | |
| secrets: | |
| AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }} | |
| notify-slack: | |
| name: Notify Slack on Failure | |
| runs-on: ubuntu-latest | |
| environment: development | |
| needs: | |
| [ | |
| check_packages, | |
| run_tests, | |
| publish_all_lambda_layers, | |
| deploy_all_lambdas, | |
| deploy_data_collection, | |
| ] | |
| if: failure() && github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v5 | |
| with: | |
| role-to-assume: ${{ secrets.AWS_ASSUME_ROLE }} | |
| role-skip-session-tagging: true | |
| aws-region: ${{ vars.AWS_REGION }} | |
| mask-aws-account-id: true | |
| - name: Get slack bot token from SSM parameter store | |
| id: ssm-parameters | |
| run: | | |
| slack_bot_token=$(aws ssm get-parameter --name "/ndr/alerting/slack/bot_token" --with-decryption --query "Parameter.Value" --output text) | |
| echo "::add-mask::$slack_bot_token" | |
| echo "SLACK_BOT_TOKEN=$slack_bot_token" >> $GITHUB_ENV | |
| - name: Send Slack Notification | |
| uses: slackapi/[email protected] | |
| with: | |
| method: chat.postMessage | |
| token: ${{ env.SLACK_BOT_TOKEN }} | |
| payload: | | |
| { | |
| "channel": "${{ vars.ALERTS_SLACK_CHANNEL_ID }}", | |
| "attachments": [ | |
| { | |
| "color": "#ff0000", | |
| "blocks": [ | |
| { | |
| "type": "header", | |
| "text": { | |
| "type": "plain_text", | |
| "text": "❌ Workflow `${{ github.workflow }}` failed" | |
| } | |
| }, | |
| { | |
| "type": "section", | |
| "text": { | |
| "type": "mrkdwn", | |
| "text": "*Triggered by:* `${{ github.actor }}`\n*Workflow:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }}>" | |
| } | |
| }, | |
| { | |
| "type": "divider" | |
| }, | |
| { | |
| "type": "section", | |
| "fields": [ | |
| { | |
| "type": "mrkdwn", | |
| "text": "*check_packages:* ${{ needs.check_packages.result == 'success' && ':white_check_mark:' || ':x:' }}" | |
| }, | |
| { | |
| "type": "mrkdwn", | |
| "text": "*run_tests:* ${{ needs.run_tests.result == 'success' && ':white_check_mark:' || ':x:' }}" | |
| }, | |
| { | |
| "type": "mrkdwn", | |
| "text": "*publish_all_lambda_layers:* ${{ needs.publish_all_lambda_layers.result == 'success' && ':white_check_mark:' || ':x:' }}" | |
| }, | |
| { | |
| "type": "mrkdwn", | |
| "text": "*deploy_all_lambdas:* ${{ needs.deploy_all_lambdas.result == 'success' && ':white_check_mark:' || ':x:' }}" | |
| }, | |
| { | |
| "type": "mrkdwn", | |
| "text": "*deploy_data_collection:* ${{ needs.deploy_data_collection.result == 'success' && ':white_check_mark:' || ':x:' }}" | |
| } | |
| ] | |
| }, | |
| { | |
| "type": "context", | |
| "elements": [ | |
| { | |
| "type": "mrkdwn", | |
| "text": "Environment: `development` | Sandbox: `ndr-dev`" | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| ] | |
| } |