Skip to content

Update recommendations now #8

Update recommendations now

Update recommendations now #8

name: Update recommendations now
on:
workflow_dispatch:
jobs:
recompute-recommendations:
runs-on: ubuntu-22.04
steps:
# Step 1: Checkout the repository with submodules
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive # Checkout submodules recursively
fetch-depth: 0 # Fetch full history to ensure submodules are up to date
# Step 2: Set up Python environment
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
# Step 3: Install dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
# Step 4: Update submodules to the latest commit
- name: Update submodules to latest
run: |
git submodule foreach 'git fetch origin main && git checkout origin/main && git pull origin main'
# Step 5: Run recommendation systems
- name: Run keyword-based recommendation system
run: python run_kwd_recs.py
- name: Run BM25 recommendation system
run: python run_bm25_recs.py
- name: Run SPECTER recommendation system
run: python run_spctr_recs.py
# Step 6: Run the unit tests
- name: Run unit tests
run: |
set +e # Continue execution even if the tests fail
python tests.py > tests.log 2>&1
cat tests.log
continue-on-error: true
# Step 7: Commit and push changes if there are any
- name: Commit and push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
git add dhq-recs*.tsv
git add dhq-journal
if [ -n "$(git status --porcelain)" ]; then
git commit -m "feat: update recommendations due to request on ${TIMESTAMP}"
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git HEAD:main
else
echo "No changes to commit"
fi