Skip to content

Cronjob

Cronjob #273

Workflow file for this run

name: "Cronjob"
on:
schedule:
- cron: '15 */6 * * *'
push:
branches:
- 'master'
jobs:
update-readme:
permissions: write-all
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21.0'
- name: Prepare
run: |
export PATH=$PATH:$(go env GOPATH)/bin
mkdir .tmp
- name: Collect weathers
run: |
go install github.com/huantt/weather-forecast@latest
weather-forecast update-weather --days=3 --city=Chiyoda-ku --weather-api-key="${{ secrets.WEATHER_API_KEY }}" --template-file='templates/weathers.md.tpl' --out-file='.tmp/weathers.md.tpl'
- name: Merge templates
run: |
go install github.com/huantt/merge-templates@v1.0.0
merge-templates README.md 'templates/README.md.tpl' '.tmp/weathers.md.tpl'
rm -rf .tmp
- name: Commit
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git add .
if git diff --cached --exit-code; then
echo "No changes to commit."
exit 0
else
git commit -m "update"
git rebase main
git push origin main
fi