The steps to create the required Google Project, Slack Webhook and GitHub Action are detailed in the following article on The New Stack: How To Use GitHub Actions and APIs to Surface Important Data
- Clone the repository
- Rename
.env.example
to.env
- Update the following variables
SLACK_WEBHOOK_URL
GA4_PROPERTY_ID
GOOGLE_APPLICATION_CREDENTIALS_BASE64
- Install dependencies (uses npm)
npm install
To invoke the function manually from your local development environment you can run the following in your terminal.
node src/index.js
The Google Application credentials are in .json
format. To use them in a .env
you can convert them to a base64 string by running the following in your terminal.
cat name-of-creds-file.json | base64
When saving the resulting string in your .env
file be sure you wrap it with quotations, e.g. GOOGLE_APPLICATION_CREDENTIALS_BASE64="abc123..."
The GitHub Action in this repo is scheduled to run each Friday at 10am UTC. A schedule uses POSIX cron syntax, e.g.
on:
schedule:
- cron: '0 10 * * 5' # Runs every Friday at 10 AM UTC
The GitHub Action in this repo contains the following which allows you trigger the workflow manually from the GitHub UI.
on:
...
- ...
workflow_dispatch: # Allows manual triggering