Skip to content

Update NOLPL database #126

Update NOLPL database

Update NOLPL database #126

Workflow file for this run

name: Update NOLPL database
on:
schedule:
- cron: 0 0 * * *
workflow_dispatch:
jobs:
scrappping:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
actions: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install poetry
run: |
curl -sSL https://install.python-poetry.org | python
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install dependencies
run: |
poetry install
- name: Launch scrapping
run: |
poetry run python noplp/create_database.py
- name: Update last scrapping date
run: |
new_line=$( echo " LAST_UPDATE: '$(date +%d/%m/%Y)'" )
old_line=$( grep LAST_UPDATE app.yaml --color=never )
sed -i -e "s@${old_line}@${new_line}@g" app.yaml
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v6
with:
base: main
commit-message: "chore(database): update database"
title: Perform scrapping to get last database version
branch: update-noplp-database
- name: Fetch branches to compare
run: |
git fetch origin update-noplp-database main --depth=1
- name: Write or update summary comment in Pull Request #see https://github.com/actions/runner/issues/1733#issuecomment-2447036317
uses: actions/github-script@v7
env:
PR_NUMBER: ${{steps.cpr.outputs.pull-request-number}}
with:
script: |
const fs = require('fs');
const { execSync } = require('child_process');
const commentBody = execSync('poetry run python noplp/compare_changes.py').toString();
const {data: comments} = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: process.env.PR_NUMBER,
})
// 41898282 is github-actions[bot] id.
const botComment = comments.find(comment => comment.user.id === 41898282)
if (!botComment) {
github.rest.issues.createComment({
issue_number: process.env.PR_NUMBER,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
})
} else {
github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: commentBody
})
}