Obliwonk - An automatic profile README updater
Obliwonk
Obliwonk is a slightly over-engineered profile README updater. Profile README is a really cool feature that allows you to add a README to your GitHub profile. It has already become a heavily used feature. To create one for yourself, you simply create a repository with your username as the repo name and add a README to it.
Now, it is fun to have a profile README, but having it self update would be even more fun. Obliwonk automates this and provides the notion of providers. Providers basically provide an abstraction over any content provider (for eg. APIs). Under the hood, a provider is just an implementation of the Provider interface.
1 type Provider interface 2 3
Two providers are already included in the box, joke and math facts provider. As the names suggest, the joke provider provides jokes and math provider provides random facts about numbers. It goes without saying, you can create custom providers as well.
Sample provider
1 type mathProvider struct 2 3
4
5 func NewMathProvider(config config.Config) Provider 6 7 8 9
10
11 func () ([]byte, error) 12 13 14 15 16 17 18 19 20 21 22
This provider just fetches a random math fact from http://numbersapi.com/random/math
There is also a utility function to randomly choose a provider so everytime Obliwonk runs, the content is random from a random provider.
Sample Config
Add .env to the project dir with the following env keys
1 OBLIWONK_GITHUB_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2 OBLIWONK_USERNAME=<github_username>
3 OBLIWONK_README=README.md
4 OBLIWONK_REPO_PRIVATE=true
5 OBLIWONK_COMMIT_MESSAGE=Updated
6 OBLIWONK_MATH_PROVIDER_URL=http://numbersapi.com/random/math
7 OBLIWONK_JOKE_PROVIDER_URL=https://official-joke-api.appspot.com/random_joke
Here the OBLIWONK_GITHUB_TOKEN is a personal access token. It needs to have repo access enabled. The default math and joke providers use the corresponding URLs, these fields already have default values and are optional.
Instructions
You could use the included Dockerfile to create a docker image and schedule it using a cron job.
1
2
You could also use GitHub Actions to schedule this workflow.
1 name: Go
2
3 on:
4 schedule:
5 - cron: 0 */2 * * *
6
7 jobs:
8
9 build:
10 name: Build
11 runs-on: ubuntu-latest
12 steps:
13
14 - name: Set up Go 1.x
15 uses: actions/setup-go@v2
16 with:
17 go-version: ^1.13
18 id: go
19
20 - name: Check out code into the Go module directory
21 uses: actions/checkout@v2
22
23 - name: Get dependencies
24 run: |
25 go get -v -t -d ./...
26 if [ -f Gopkg.toml ]; then
27 curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
28 dep ensure
29 fi
30 - name: Build
31 run: go build
32
33 - name: Touch .env
34 run: touch .env
35
36 - name: Run obliwonk
37 env:
38 OBLIWONK_GITHUB_TOKEN: ${{ secrets.OBLIWONK_TOKEN }}
39 OBLIWONK_USERNAME: ${{ secrets.OBLIWONK_USERNAME }}
40 OBLIWONK_README: README.md
41 OBLIWONK_COMMIT_MESSAGE: ${{ secrets.OBLIWONK_COMMIT_MESSAGE }}
42 OBLIWONK_MATH_PROVIDER_URL: ${{ secrets.OBLIWONK_MATH_PROVIDER_URL }}
43 OBLIWONK_JOKE_PROVIDER_URL: ${{ secrets.OBLIWONK_JOKE_PROVIDER_URL }}
44 run: ./obliwonk
Create a file .github/workflows/go.yml. You will also have to create the corresponding secrets. You would have to create a new personal access token and give it repo access instead of using the default workflows GitHub token.
Conclusion
This project is still a WIP. Some features that I would like to add include:
- Add support for templates
- Add more providers like GIF provider, News provider etc.
The project is hosted at https://github.com/cvhariharan/obliwonk