Send Email on Holidays Update #2239
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Send Email on Holidays Update | |
on: | |
schedule: | |
# 从 00:00 到 10:00 UTC,每 2 小时运行一次(对应北京时间 08:00 到 06:00) | |
- cron: '0 0-10/2 * * *' | |
# Allows you to run this workflow manually from the Actions tab on GitHub. | |
workflow_dispatch: | |
jobs: | |
notify: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
registry-url: "https://registry.npmjs.org" | |
- name: Install dependencies | |
run: npm install | |
- name: Run script | |
id: run-script | |
run: npm run fetch ${{ vars.HOLIDAYS_YEAR }} | |
- name: Read holidays file | |
id: read-holidays | |
run: | | |
echo "HOLIDAYS_CONTENT=$(cat holidays.html)" >> $GITHUB_ENV | |
env: | |
HOLIDAYS_CONTENT: $(cat holidays.html) | |
- name: Send notification if holidays has value | |
if: ${{ steps.run-script.outputs.holidays != '' }} | |
uses: dawidd6/action-send-mail@v3 | |
with: | |
server_address: smtp.gmail.com | |
server_port: 587 | |
username: ${{ secrets.EMAIL_USERNAME }} | |
password: ${{ secrets.EMAIL_PASSWORD }} | |
subject: "${{ vars.HOLIDAYS_YEAR }} Holidays Update" | |
to: ${{ secrets.TO_EMAIL }} | |
from: Holidays Update | |
html_body: ${{ env.HOLIDAYS_CONTENT }} |