Skip to content

Commit

Permalink
weather-bot
Browse files Browse the repository at this point in the history
  • Loading branch information
ytanck committed Oct 17, 2023
1 parent 44538ab commit 0336398
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
7 changes: 0 additions & 7 deletions .github/dependabot.yml

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/WeatherBot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: 'GitHub Actions Weather Bot'

on:
push:
workflow_dispatch:
schedule:
- cron: '40 06 * * *'

jobs:
bot:
runs-on: ubuntu-latest
steps:
- name: 'Checkout codes'
uses: actions/checkout@v1
- name: 'Get Weather'
run: bash ./weather.sh
- name: 'Get Date'
run: echo "REPORT_DATE=$(TZ=':Asia/Wuhan' date '+%Y-%m-%d %T')" >> $GITHUB_ENV
- name: 'Send mail'
uses: dawidd6/action-send-mail@master
with:
server_address: smtp.qq.com
server_port: 465
username: ${{ secrets.MAIL_USERNAME }}
password: ${{ secrets.MAIL_PASSWORD }}
subject: 武汉天气预报 (${{env.REPORT_DATE}})
html_body: file://result.html
to: 307330552@qq.com
from: GitHub Actions
14 changes: 14 additions & 0 deletions weather.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

set -eux

CITY=Wuhan
LANGUAGE="zh-CN"
UNIT=m
UA="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36"

curl \
-H "Accept-Language: $LANGUAGE" \
-H "User-Agent: $UA" \
-o result.html \
https://wttr.in/$CITY?format=4\&$UNIT

0 comments on commit 0336398

Please sign in to comment.