Skip to content

Fetch and deploy

Fetch and deploy #322

Workflow file for this run

name: "Fetch and deploy"
on:
workflow_dispatch:
schedule:
- cron: "30 7 * * MON,THU,SAT" # “At 07:30 on Monday, Thursday, and Saturday.” (UTC)
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: checkout repo content
uses: actions/checkout@v4 # checkout the repository content to github runner
- name: setup python
uses: actions/setup-python@v5
with:
python-version: "3.10" # install the python version needed
- name: install python packages
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: execute py script # run fetcher.py to get the latest data
env:
AZURE_KEY1: ${{ secrets.AZURE_KEY1 }}
# AZURE_KEY2: ${{ secrets.AZURE_KEY2 }}
run: python fetcher.py
- name: commit files
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add -A
git commit -m ":card_file_box: Update db `date +"%d-%m-%Y"`" -a
- name: push changes
uses: ad-m/github-push-action@v0.8.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: master
deploy:
runs-on: ubuntu-latest
needs: update
steps:
- name: checkout repo content
uses: actions/checkout@v3 # checkout the repository content to github runner
with:
ref: master
- name: Deploy to Heroku
uses: akhileshns/heroku-deploy@v3.13.15
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: "astros-api" #Must be unique in Heroku
heroku_email: "iqmal3@outlook.com"
notify:
runs-on: ubuntu-latest
needs: deploy
steps:
- name: Telegram notify
uses: fjogeleit/http-request-action@v1
with:
url: "https://api.telegram.org/bot${{secrets.TELE_BOT_API_KEY}}/sendMessage"
method: "POST"
data: '{
"chat_id": -1001591844692,
"parse_mode": "MarkdownV2",
"disable_web_page_preview": true,
"text": "${{github.workflow}} *completed* 🛰 \\. Triggered by `${{github.event_name}}`\\. View [website](https:\/\/astros-api.herokuapp.com) or [action runs](https:\/\/github.com\/${{github.repository}}\/actions\/runs\/${{github.run_id}})\\."
}'