Generate Postmarket Report #367
This file contains 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
# setup python and setup golang github actions | |
name: Generate Postmarket Report | |
on: | |
schedule: | |
# make this report at 2:30 PM PST | |
- cron: '30 20 * * *' | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
env: | |
REDDIT_CLIENT_ID: ${{ secrets.REDDIT_CLIENT_ID }} | |
REDDIT_CLIENT_SECRET: ${{ secrets.REDDIT_CLIENT_SECRET }} | |
REDDIT_PASSWORD: ${{ secrets.REDDIT_PASSWORD }} | |
REDDIT_USERNAME: ${{ secrets.REDDIT_USERNAME }} | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_URGENT_NOTIFICATIONS_WEBHOOK}} | |
DETA_TOKEN: ${{ secrets.DETA_TOKEN }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.10.7 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
cd src | |
pip install -r requirements.core.txt | |
pip install -r requirements.post.txt | |
# cd ../OpenBBTerminal | |
# ls | |
# pip install -r requirements.txt | |
- uses: actions/setup-go@v3 | |
with: | |
go-version: '>=1.17.0' | |
- run: go version | |
- name: Generate Postmarket Report | |
run: | | |
python src/gen_postreport.py | |
- name: git pull and set config to merge | |
run: | | |
git stash | |
git config --global pull.rebase false | |
git pull -X theirs | |
git cherry-pick -n -m1 -Xtheirs stash | |
- uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: "Update Postmarket Report" | |
commit_options: '--no-verify' | |
commit_user_name: github-actions | |
# in the future use a simplifed approach to commiting and pushing with multiple jobs | |
- name: Compile LaTeX document | |
uses: xu-cheng/latex-action@v2 | |
with: | |
root_file: data/latest.tex | |
args: -interaction=nonstopmode | |
latexmk_use_lualatex: true | |
- name: upload artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: latest | |
path: latest.pdf | |
# TODO replace with my own code | |
# - name: send pdf to discord | |
# uses: appleboy/discord-action@master | |
# with: | |
# webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }} | |
# webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }} | |
# file: data/latest.pdf | |
- name: Send report to discord | |
run: | |
python src/send_discord.py --content "Postmarket Report" --username "stonk_events" | |
- name: Upload file to deta space | |
run: | |
# remove latest.pdf to current date | |
ls latest.pdf | |
python src/upload_to_deta.py latest.pdf $(date +%Y-%m-%d)_post.pdf | |
- uses: sarisia/actions-status-discord@v1 | |
if: failure() | |
with: | |
webhook: ${{ secrets.DISCORD_CODE_STATUS_WEBHOOK }} | |
status: ${{ job.status }} | |
title: ${{github.repository}} | |
description: "Failed to generate postmarket report" | |
nofail: false | |
noprefix: false | |
color: 0xff0000 | |
username: stonk_events |