Run Python Script with Virtual Environment #2728
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: Run Python Script with Virtual Environment | |
on: | |
workflow_dispatch: # Manual trigger | |
schedule: | |
- cron: "*/5 * * * *" # Runs every 5 minutes | |
jobs: | |
python_job: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.13' | |
- name: Set up virtual environment | |
run: | | |
python3 -m venv .venv | |
source .venv/bin/activate | |
pip3 install --upgrade pip | |
- name: Install dependencies | |
run: | | |
source .venv/bin/activate | |
pip3 install -r requirements.txt | |
- name: Debug environment variables and run script | |
run: | | |
echo "NOTION_API_TOKEN is set: ${NOTION_API_TOKEN:+Yes}" | |
echo "NOTION_PAGE_ID is set: ${NOTION_PAGE_ID:+Yes}" | |
source .venv/bin/activate | |
python3 ntn_hello_world.py | |
env: | |
NOTION_API_TOKEN: ${{ secrets.NOTION_API_TOKEN }} | |
NOTION_PAGE_ID: ${{ secrets.NOTION_PAGE_ID }} | |