From 033639835f432e4ecb9a71a527e6bf00c13ad8a3 Mon Sep 17 00:00:00 2001 From: yangtao Date: Tue, 17 Oct 2023 14:34:55 +0800 Subject: [PATCH] weather-bot --- .github/dependabot.yml | 7 ------- .github/workflows/WeatherBot.yml | 29 +++++++++++++++++++++++++++++ weather.sh | 14 ++++++++++++++ 3 files changed, 43 insertions(+), 7 deletions(-) delete mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/WeatherBot.yml create mode 100644 weather.sh diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 93385d99..00000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,7 +0,0 @@ -version: 2 -updates: -- package-ecosystem: npm - directory: "/" - schedule: - interval: daily - open-pull-requests-limit: 20 diff --git a/.github/workflows/WeatherBot.yml b/.github/workflows/WeatherBot.yml new file mode 100644 index 00000000..7133b5ee --- /dev/null +++ b/.github/workflows/WeatherBot.yml @@ -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 \ No newline at end of file diff --git a/weather.sh b/weather.sh new file mode 100644 index 00000000..39f3deac --- /dev/null +++ b/weather.sh @@ -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 \ No newline at end of file