Update recommendations biweekly #2
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: Update recommendations biweekly | |
on: | |
schedule: | |
- cron: '0 0 1,15 * *' | |
workflow_dispatch: | |
jobs: | |
check-and-recompute: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install -r requirements.txt | |
- name: Check for submodule updates | |
id: submodule_check | |
run: | | |
git submodule foreach 'git fetch origin main && git checkout origin/main && git pull origin main' | |
if [ "$(git status --porcelain)" != "" ]; then | |
echo "submodule_updated=true" >> $GITHUB_ENV | |
else | |
echo "submodule_updated=false" >> $GITHUB_ENV | |
fi | |
- name: Run keyword-based recommendation system | |
if: env.submodule_updated == 'true' | |
run: python run_kwd_recs.py | |
- name: Run BM25 recommendation system | |
if: env.submodule_updated == 'true' | |
run: python run_bm25_recs.py | |
- name: Run SPECTER recommendation system | |
if: env.submodule_updated == 'true' | |
run: python run_spctr_recs.py | |
- name: Run unit tests | |
run: | | |
set +e | |
python tests.py > tests.log 2>&1 | |
cat tests.log | |
continue-on-error: true | |
- name: Commit and push changes | |
if: env.submodule_updated == 'true' | |
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 | |
git commit -m "feat: update recommendations due to submodule update on ${TIMESTAMP}" | |
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git HEAD:main |