Scrape #88
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
name: Scrape | |
on: | |
workflow_dispatch: | |
inputs: | |
accountsToScrape: | |
default: "" | |
required: false | |
description: "Accounts to scrape (comma separated)" | |
daysBack: | |
default: "1" | |
required: false | |
description: "Days back to scrape" | |
scrapeFromBeginningOfMonth: | |
default: true | |
required: false | |
description: "If true, the days back will be caluclated automacitlly from the beginning of the month" | |
worksheetName: | |
default: "current" | |
required: false | |
description: "The name of the worksheet to write to" | |
schedule: | |
- cron: "00 06 * * *" | |
env: | |
IMAGE_NAME: ghcr.io/${{ github.repository }}:latest | |
jobs: | |
scrape: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4.1.1 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.x" | |
- name: Run python script | |
run: | | |
current_date=$(date +"%Y-%m-%d") | |
day=$(date -d "$current_date" +"%d") | |
if [ "$day" = "01" ]; then | |
printf "%s\n" "$GOOGLE_JSON" > google.json | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
python gpt.py | |
else | |
printf "%s\n" "$GOOGLE_JSON" > google.json | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
python gpt.py | |
echo "It is not the first day of the month." | |
fi | |
env: | |
GOOGLE_JSON: ${{ secrets.GOOGLE_JSON }} | |
- name: Pull image | |
run: docker pull $IMAGE_NAME | |
- name: Run scraper | |
run: docker run --rm | |
-e DEBUG | |
-e DAYS_BACK | |
-e TZ | |
-e WORKSHEET_NAME | |
-e ACCOUNTS_JSON | |
-e TELEGRAM_API_KEY | |
-e TELEGRAM_CHAT_ID | |
-e GOOGLE_SHEET_ID | |
-e GOOGLE_SERVICE_ACCOUNT_EMAIL | |
-e GOOGLE_SERVICE_ACCOUNT_PRIVATE_KEY | |
-e ACCOUNTS_TO_SCRAPE | |
-e ADE_DATABASE_NAME | |
-e ADE_TABLE_NAME | |
-e ADE_INGESTION_MAPPING | |
-e ADE_INGEST_URI | |
-e AZURE_TENANT_ID | |
-e AZURE_APP_ID | |
-e AZURE_APP_KEY | |
-e SCRAPE_FROM_BEGINNING_OF_MONTH | |
$IMAGE_NAME | |
env: | |
DEBUG: "" | |
TZ: "UTC" | |
DAYS_BACK: ${{ github.event.inputs.daysBack }} | |
WORKSHEET_NAME: ${{ github.event.inputs.worksheetName || 'current' }} | |
SCRAPE_FROM_BEGINNING_OF_MONTH: ${{ github.event.inputs.scrapeFromBeginningOfMonth || true }} | |
ACCOUNTS_TO_SCRAPE: ${{ github.event.inputs.accountsToScrape }} | |
ACCOUNTS_JSON: ${{ secrets.ACCOUNTS_JSON }} | |
TELEGRAM_API_KEY: ${{ secrets.TELEGRAM_API_KEY }} | |
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} | |
GOOGLE_SHEET_ID: ${{ secrets.GOOGLE_SHEET_ID }} | |
GOOGLE_SERVICE_ACCOUNT_EMAIL: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_EMAIL }} | |
GOOGLE_SERVICE_ACCOUNT_PRIVATE_KEY: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_PRIVATE_KEY }} | |
ADE_DATABASE_NAME: ${{ secrets.ADE_DATABASE_NAME }} | |
ADE_TABLE_NAME: ${{ secrets.ADE_TABLE_NAME }} | |
ADE_INGESTION_MAPPING: ${{ secrets.ADE_INGESTION_MAPPING }} | |
ADE_INGEST_URI: ${{ secrets.ADE_INGEST_URI }} | |
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} | |
AZURE_APP_ID: ${{ secrets.AZURE_APP_ID }} | |
AZURE_APP_KEY: ${{ secrets.AZURE_APP_KEY }} | |
- name: Send Uodate | |
uses: fjogeleit/http-request-action@v1 | |
with: | |
url: "${{ secrets.UPDATE_WEB_HOOK }}" | |
method: "GET" |