Skip to content

newsletter

newsletter #1506

Workflow file for this run

name: 'newsletter'
on:
workflow_dispatch:
schedule:
- cron: '2 0 * * *'
jobs:
newsletter:
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- uses: actions/checkout@v4
- name: Cache node modules
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- run: npm i
- name: 'Set Args'
run: |
echo "TZ=Asia/Shanghai" >> $GITHUB_ENV
echo "HTML_OUTPUT=result.html" >> $GITHUB_ENV
echo "TEXT_OUTPUT=result.txt" >> $GITHUB_ENV
echo "POST_DATE=$(TZ=':Asia/Shanghai' date --date=' 1 days ago' '+%Y%m%d')" >> $GITHUB_ENV
- shell: bash
env:
LEANCLOUD_APP_ID: ${{ secrets.US_LEANCLOUD_APP_ID }}
LEANCLOUD_APP_KEY: ${{ secrets.US_LEANCLOUD_APP_KEY }}
LEANCLOUD_MASTER_KEY: ${{ secrets.US_LEANCLOUD_MASTER_KEY }}
run: |
node actions/newsletter.js --day ${{ env.POST_DATE }} --htmloutput ${{ env.HTML_OUTPUT }} --textoutput ${{ env.TEXT_OUTPUT }}
title=$(head -2 github-issue.md | grep title | sed 's/title: //' | sed 's/"//g')
echo "TITLE=$title" >> $GITHUB_ENV
- name: Create github issue
uses: JasonEtco/create-an-issue@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
filename: github-issue.md
- name: Send telegram
run: |
export TELEGRAM_TOKEN=${{ secrets.TELEGRAM_TOKEN }}
export TELEGRAM_CHAT_ID="@mofish_break"
export TELEGRAM_MESSAGE_FILE=telegram-bot.md
node actions/telegram.mjs
- name: 'Send mail'
uses: dawidd6/action-send-mail@v3
with:
server_address: ${{ secrets.SMTP_SERVER }}
server_port: ${{ secrets.SMTP_PORT }}
username: ${{ secrets.MAIL_USERNAME }}
password: ${{ secrets.MAIL_PASSWORD }}
subject: ${{env.TITLE}}
body: file://${{ env.TEXT_OUTPUT }}
html_body: file://${{ env.HTML_OUTPUT }}
to: [email protected]
from: Hot Posts Digest