Dispatch analytics #1749
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: Dispatch analytics | |
# PROCESS | |
# | |
# 1. Trade GitHub JWT token with AWS credentials for the analytics account | |
# 2. Invoke a Lambda function dispatcher synchronously with the read-only scoped JWT token | |
# 3. The dispatcher function will call GitHub APIs to read data from the last hour and aggregate for operational analytics | |
# USAGE | |
# | |
# NOTE: meant to use as a scheduled task only (or manually for debugging purposes). | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 * * * *" | |
permissions: | |
id-token: write | |
actions: read | |
checks: read | |
contents: write | |
deployments: read | |
issues: read | |
discussions: read | |
packages: read | |
pages: read | |
pull-requests: read | |
repository-projects: read | |
security-events: read | |
statuses: read | |
jobs: | |
dispatch_token: | |
if: github.repository == 'awslabs/aws-lambda-powertools-python' | |
concurrency: | |
group: analytics | |
runs-on: ubuntu-latest | |
environment: analytics | |
steps: | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@5727f247b64f324ec403ac56ae05e220fd02b65f # v2.1.0 | |
with: | |
aws-region: eu-central-1 | |
role-to-assume: ${{ secrets.AWS_ANALYTICS_ROLE_ARN }} | |
- name: Invoke Lambda function | |
run: | | |
payload=$(echo -n '{"githubToken": "${{ secrets.GITHUB_TOKEN }}"}' | base64) | |
aws lambda invoke \ | |
--function-name ${{ secrets.AWS_ANALYTICS_DISPATCHER_ARN }} \ | |
--payload "$payload" response.json | |
cat response.json |