This GitHub Actions workflow is designed to update a README file with your Wakatime statistics. It utilizes a GitHub access token, your Wakatime API key, and your Wakatime user ID to fetch and display your coding activity on your repository's README file.
Before you can use this workflow, you need to ensure you have the following:
-
Wakatime Account :
- WakaTime is a developer productivity tool and time tracking service specifically designed for software developers. It helps developers keep track of how much time they spend working on various programming tasks, coding projects, and programming languages.
-
Wakatime API Key :
- You need your Wakatime API key, which you can obtain from your Wakatime account settings.
-
Wakatime User ID :
- Your Wakatime User ID is required to fetch your coding statistics. You can find it in your Wakatime account settings.
-
Create a personal repository
- Your personal repository is a special repository that has the same name as your username.
It matches the following pattern :
<your-username>/<your-username>
. Example : https://github.com/claserre9/claserre9
- Your personal repository is a special repository that has the same name as your username.
It matches the following pattern :
-
GitHub Access Token :
- You should have a GitHub access token with the
repo
scope. If you don't have one, you can create it in your GitHub account settings.
- You should have a GitHub access token with the
To set up and use this GitHub Actions workflow in your repository, follow these steps:
-
Create Workflow File :
- Create a new GitHub Actions workflow file in your personal repository.
For example, you can create a
.github/workflows/wakatime-stats.yml
file.
- Create a new GitHub Actions workflow file in your personal repository.
For example, you can create a
-
Update your README :
- Add the following markdown comments to where you want the stats to be generated in your README file.
[//]: # (wakatime-stats) [//]: # (end-wakatime-stats)
The Wakatime stats will appear between these two markdown comments
-
Configure Workflow :
-
In the workflow file, specify the following input parameters:
GH_TOKEN
: Your GitHub access token.WAKATIME_API_KEY
: Your Wakatime API Key.WAKATIME_USER_ID
: Your Wakatime User ID.
-
Example:
name: Wakatime Stats on: workflow_dispatch: schedule: - cron: '0 0 * * *' #Will run at midnight every day. Free to change according to your needs jobs: update-readme: runs-on: ubuntu-latest steps: - name: Checkout Code uses: actions/checkout@v2 - name: Update README with Wakatime Stats env: GH_TOKEN: ${{ secrets.GH_TOKEN }} WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }} WAKATIME_USER_ID: ${{ secrets.WAKATIME_USER_ID }}
-
-
Secrets :
-
Run Workflow:
- The workflow will be triggered when you push changes to your repository's main branch, as per the example configuration. You can customize the trigger events as needed.
-
Full Setup Example
name: Wakatime Stats on: workflow_dispatch: schedule: - cron: '0 0 * * *' # Run at midnight every day jobs: update-readme-with-wakatime-stats: name: Update README with Wakatime stats runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - uses: claserre9/wakatime-stats@v1 with: WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }} WAKATIME_USER_ID: ${{ secrets.WAKATIME_USER_ID }} GH_TOKEN: ${{ secrets.GH_TOKEN }} TABLE_STYLE: 'default' # (optional) can be 'default','box' or 'box-double' MAX_LANGUAGES: '5' # (optional) any number > 5, if under 5, this will be set to 5 WAKATIME_TIME_RANGE: 'all_time' # (optional) can be 'last_7_days', 'last_30_days', 'last_6_months' or 'last_year'
This GitHub Actions workflow is provided under the MIT License.