From bf0cb2be84d25aed9d48bf3bca4bcfb15c0f26f4 Mon Sep 17 00:00:00 2001 From: Arkadii Yakovets Date: Mon, 16 Sep 2024 18:26:18 -0700 Subject: [PATCH] Add data update cron job --- .github/ansible/staging/update-data.yaml | 6 ++++++ .github/workflows/update-data.yaml | 18 ++++++++++++++++++ Makefile | 6 +++--- 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 .github/ansible/staging/update-data.yaml create mode 100644 .github/workflows/update-data.yaml diff --git a/.github/ansible/staging/update-data.yaml b/.github/ansible/staging/update-data.yaml new file mode 100644 index 000000000..cd58fe3c4 --- /dev/null +++ b/.github/ansible/staging/update-data.yaml @@ -0,0 +1,6 @@ +- name: Run Nest Staging Data Update + hosts: nest_staging + tasks: + - name: Start services + shell: + cmd: 'make update-data' diff --git a/.github/workflows/update-data.yaml b/.github/workflows/update-data.yaml new file mode 100644 index 000000000..41ea54d08 --- /dev/null +++ b/.github/workflows/update-data.yaml @@ -0,0 +1,18 @@ +name: Update data + +on: + schedule: + - cron: '0 1 * * *' + workflow_dispatch: + +env: + FORCE_COLOR: 1 + +jobs: + update-data: + name: Run data update + runs-on: ubuntu-latest + steps: + - name: Run make update-data + working-directory: .github/ansible + run: ansible-playbook -i inventory.yaml staging/update-data.yaml diff --git a/Makefile b/Makefile index 5f71c6132..5a68a2561 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ github-sync-related-repositories: github-enrich-issues: @CMD="poetry run python manage.py github_enrich_issues" $(MAKE) exec-backend-command -index: +index-data: @CMD="poetry run python manage.py algolia_reindex" $(MAKE) exec-backend-command load-data: @@ -59,7 +59,7 @@ setup: shell: @CMD="/bin/bash" $(MAKE) exec-backend-command -sync: \ +sync-data: \ github-sync-owasp-organization \ owasp-scrape-site-data \ github-sync-related-repositories \ @@ -70,4 +70,4 @@ test: @docker build -f backend/Dockerfile.test backend -t nest-backend-test 2>/dev/null @docker run -e DJANGO_CONFIGURATION=Test nest-backend-test poetry run pytest -update: sync index +update-data: sync-data index-data