| Date | 23/12/2025 | 24/12/2025 | 25/12/2025 |
|---|---|---|---|
| Weather | |||
| Condition | Patchy rain nearby | Patchy rain nearby | Patchy rain nearby |
| Temperature | 20 - 25.8 °C | 19.6 - 26 °C | 14.6 - 20 °C |
| Wind | 19.4 kph | 19.8 kph | 27.4 kph |
Updated at: 2025-12-22T19:27:03Z
View
You can easily embed tables in your README.md using GitHub Actions by following these simple steps:
Step 1: In your repository, create a file named README.md.template.
Step 2: Write anything you want within the README.md.template file.
Step 3: Embed one of the following entities within your README.md.template:
- Today's Weather Table:
{{ template "hourly-table" $.TodayWeather.HourlyWeathers }}- Daily Weather Table:
{{ template "daily-table" .Weathers }}- Updated at:
{{ formatTime .UpdatedAt }}If you are familiar with Go templates, you have access to the root variable, which includes the following fields:
Weathers: An array of daily Weather. You can view the Weather struct definition in model/weather.go.UpdatedAt: This field contains the timestamp in the format oftime.Date.
Step 4: Register Github Action
- Create a file
.github/workflows/update-weather.ymlin your repository.
name: "Cronjob"
on:
schedule:
- cron: '15 * * * *'
jobs:
update-weather:
permissions: write-all
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Generate README
uses: huantt/weather-forecast@v1.0.5
with:
city: HaNoi
days: 7
weather-api-key: ${{ secrets.WEATHER_API_KEY }}
template-file: 'README.md.template'
out-file: 'README.md'
- name: Commit
run: |
if git diff --exit-code; then
echo "No changes to commit."
exit 0
else
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git commit -m "update"
git push origin main
fi- Update some variable in this file:
- city: The city that you want to forecast weather
- days: number of forecast days
- template-file: Path to the above template file. Eg.
template/README.md.template - out-file: your README.md file name
- weather-api-key:
- Register free API key in https://weatherapi.com
- Setup secrets with name
WEATHER_API_KEYinYour repo > settings > Secrets and variables > Actions > New repository secret
Step 5: Commit your change, then Github actions will run as your specificed cron to update Weather into your README.md file
View
go install https://github.com/huantt/weather-forecastUsage:
weather-forecast update-weather [flags]
Flags:
--city string City
--days int Days of forecast (default 7)
-h, --help help for update-weather
-o, --out-file string Output file path
-f, --template-file string Readme template file path
-k, --weather-api-key string weatherapi.com API key
Sample
weather-forecast update-weather \
--days=7 \
--weather-api-key="$WEATHER_API_KEY" \
--template-file='template/README.md.template' \
--city=HaNoi \
--out-file='README.md'docker build -t weather-forecast .docker run --rm \
-v ./:/app/data \
weather-forecast \
--weather-api-key='XXXX' \
--city=HaNoi \
--out-file=data/README.md \
--template-file=data/README.md.template