This Spin application pulls the stargazer count of a repo of your choosing for the current day. It then stores the {date
: stargazer_count
} pair in a Spin key-value store.
You can see an example running at https://stargazer-counter.fermyon.app/static/index.html
Spin features used
- Spin Key Value Store
- Variable config
- Fermyon Cloud Custom Subdomain
- Spin's static fileserver template
- Spin version 1.3 or newer
- Spin Python SDK
- Fermyon Cloud account
- Cron-job account
- GitHub Personal Access Toke
- Clone the repo, and modify
spin.toml
After cloning this repo, take a look at spin.toml
and update the following values with your credentials and preferred target
[component.config]
# this is your GH PAT
gh_auth_token = "{{ gh_auth_token }}"
# this is the owner of the repo you want to pull stargazer count from
owner = "fermyon"
# this is the repo youi want to pull stargazer count from
repo = "spin"
- Run application locally to ensure everything works as expected
Build and deploy Spin app locally:
SPIN_CONFIG_GH_AUTH_TOKEN="{SECRET}" spin build --up
Check to see stargazer count:
curl localhost:3000
Optionally, this can be viewed on KV explorer as well at the following URL: http://localhost:3000/internal/kv-explorer.
- Deploy to Fermyon Cloud
spin cloud deploy --variable gh_auth_token="{YOUR_PAT}"
-
Apply custom fermyon subdomain (optional) Choose a friendly name of your choice following this tutorial.
-
Set up cron job at a daily reoccurance, pointing at our custom Fermyon subdomain (or default domain name if you skipped step 4):
Complete :)