Skip to content

APM Deploy for Production #46

APM Deploy for Production

APM Deploy for Production #46

name: APM Deploy for Production
on:
schedule:
- cron: "30 9 * * 1"
workflow_dispatch:
permissions:
id-token: write
contents: read
jobs:
build-workflow:
name: Deploy APM
environment: production
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_branch }}
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: NPM install
run: npm ci
working-directory: ./workflow-cli
- name: Download Maxmind DB
env:
MAXMIND_LICENSE_KEY: ${{ secrets.MAXMIND_LICENSE_KEY }}
run: ./bin/dev lambda-asset-download
working-directory: ./workflow-cli
- name: Generate aws template
run: ./bin/dev aws-render
working-directory: ./workflow-cli
- name: Setup AWS SAM
uses: aws-actions/setup-sam@v2
with:
use-installer: true
- name: Get AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-session-name: GitHub_to_AWS_via_FederatedOIDC
aws-region: ${{ vars.AWS_REGION }}
- name: Cache SAM Build
id: cache-sam-build
uses: actions/cache@v4
with:
path: .aws-sam
key: ${{ github.sha }}-sam-cache
- name: Run SAM build
if: steps.cache-sam-build.outputs.cache-hit != 'true'
run: sam build --cached
# - name: SAM View Changeset
# env:
# AWS_OPENSEARCH_URL: ${{ vars.AWS_OPENSEARCH_URL }}
# AWS_KINESIS_STREAM_SHARD_COUNT: ${{ vars.AWS_KINESIS_STREAM_SHARD_COUNT }}
# run: |
# sam deploy \
# --stack-name nr-apm-stack \
# --no-execute-changeset \
# --no-fail-on-empty-changeset \
# --parameter-overrides \
# "LambdaHandler=index.kinesisStreamHandler" \
# "KinesisStreamShardCount=$AWS_KINESIS_STREAM_SHARD_COUNT" \
# "OpensearchUrl=$AWS_OPENSEARCH_URL"
- name: SAM deploy
env:
AWS_OPENSEARCH_URL: ${{ vars.AWS_OPENSEARCH_URL }}
AWS_KINESIS_STREAM_SHARD_COUNT: ${{ vars.AWS_KINESIS_STREAM_SHARD_COUNT }}
run: |
sam deploy \
--stack-name nr-apm-stack \
--no-confirm-changeset \
--no-fail-on-empty-changeset \
--parameter-overrides \
"LambdaHandler=index.kinesisStreamHandler" \
"KinesisStreamShardCount=$AWS_KINESIS_STREAM_SHARD_COUNT" \
"OpensearchUrl=$AWS_OPENSEARCH_URL"