-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (76 loc) · 2.72 KB
/
scrapping.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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
})
}