name: Update Job Database on: schedule: - cron: "0 0 * * 1-6" # Daily at midnight (Monday through Saturday) (main.py) - cron: "0 0 * * 0" # Weekly on Sunday at midnight (training_pipeline.ipynb) workflow_dispatch: # Allows manual triggering permissions: contents: write jobs: daily-update: runs-on: ubuntu-latest if: github.event.schedule != '0 0 * * 0' # Skip on Sunday steps: - name: Checkout repository uses: actions/checkout@v3 with: token: ${{ secrets.GITHUB_TOKEN }} fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v4 with: python-version: "3.10" - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt - name: Set timezone uses: szenius/set-timezone@v1.2 with: timezoneLinux: "Europe/Stockholm" - name: Run daily update script env: PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }} run: python main.py - name: Update and push changes run: | git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" git add timestamp2.txt git diff --quiet && git diff --staged --quiet || (git commit -m "Update timestamp" && git push origin main) - name: Push to Hugging Face Space if: success() env: HF_TOKEN: ${{ secrets.HF_TOKEN }} run: | git remote add hf https://user:${HF_TOKEN}@huggingface.co/spaces/forestav/jobsai git push hf main:main --force weekly-training: runs-on: ubuntu-latest if: github.event.schedule == '0 0 * * 0' # Only run on Sunday steps: - name: Checkout repository uses: actions/checkout@v3 with: token: ${{ secrets.GITHUB_TOKEN }} fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v4 with: python-version: "3.10" - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt pip install nbconvert jupyter - name: Run training pipeline env: HF_TOKEN: ${{ secrets.HF_TOKEN }} HOPSWORKS_API_KEY: ${{ secrets.HOPSWORKS_API_KEY }} run: | jupyter nbconvert --to python training_pipeline.ipynb python training_pipeline.py - name: Run bootstrap script env: PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }} run: python bootstrap.py - name: Commit changes run: | git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" git add . git diff --quiet && git diff --staged --quiet || git commit -m "Weekly training update" - name: Push to GitHub run: | git fetch origin main git pull origin main --rebase git push origin main - name: Push to Hugging Face Space if: success() env: HF_TOKEN: ${{ secrets.HF_TOKEN }} run: | git remote add hf https://user:${HF_TOKEN}@huggingface.co/spaces/forestav/jobsai git push hf main:main --force