A bot designed to run on Azure Functions and post things into the Console Basecamp chat room. Runs using a Custom Request Handler which receives HTTP requests and responds like a web app.
post_mailchimp_stats: posts the latest stats from Mailchimp.
Uses Rocket so requires Rust nightly. Set up a nightly override on the directory once cloned:
rustup override set nightlySet environment variables (see below) with the relevant config then run:
cargo runto start the web server. Issue requests to the endpoints e.g.:
curl -i -X POST -H "Content-Type:application/json" -d "{}" http://localhost:3000/post_mailchimp_statscargo testRequirements:
# Create the local.settings.json file which will set the environment variables
# Only required on a fresh clone when the file doesn't exist
func azure functionapp fetch-app-settings bc-totorobot
func startcurl -i -X POST -H "Content-Type:application/json" -d "{}" http://localhost:7071/admin/functions/post_mailchimp_statsTOTORO_MAILCHIMP_APIKEY: Mailchimp API key.TOTORO_MAILCHIMP_LIST_ID: Mailchimp list ID string.TOTORO_BASECAMP_BOTURL: URL to post to in Basecamp.TOTORO_PRODUCTION: Set to any value when running in production.
Create a new tag with the name format release-vx.y.z where x.y.z is a
semantic versioning formatted version string e.g. release-v0.1.4
Azure
uses
the x86_64-unknown-linux-musl platform. Builds are done through a dedicated
Docker container that has various C
libraries built against musl.
Azure resources defined in main.bicep.
Requirements:
- Docker e.g.
sudo paman install docker - Bicep
- Azure CLI
- Azure Functions Core Tools
docker pull clux/muslrust
docker run -v $PWD:/volume --rm -t clux/muslrust cargo build --release
mkdir bin # host.json configured to expect binary here
cp target/x86_64-unknown-linux-musl/release/totorobot bin/
bicep build ./main.bicep # generates main.json
az login
az deployment group create -f ./main.json -g bc-totorobot
func azure functionapp publish bc-totorobotUses Azure ARM and Login GitHub actions to deploy.
AZURE_CREDENTIALS created as per the service principal
instructions.
az ad sp create-for-rbac --name "bc-totorobot - GitHub" --sdk-auth --role contributor \
--scopes /subscriptions/SUBSCRIPTIONID/resourceGroups/bc-totorobot