mirror of
https://github.com/ai-robots-txt/ai.robots.txt.git
synced 2025-04-19 00:26:01 +00:00
Adding GitHub Action
This commit is contained in:
parent
17a84f2c2d
commit
1fdc79dacb
3 changed files with 244 additions and 0 deletions
28
code/action.php
Normal file
28
code/action.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
This script processes updates to the https://github.com/ai-robots-txt/ai.robots.txt repository.
|
||||
|
||||
It generates:
|
||||
|
||||
- robots.txt
|
||||
- table-of-bot-metrics.md
|
||||
|
||||
*/
|
||||
|
||||
$robots = json_decode(file_get_contents('robots.json'), 1);
|
||||
|
||||
$robots_txt = null;
|
||||
$robots_table = '| Name | Operator | Respects `robots.txt` | Data use | Visit regularity | Description |'."\n";
|
||||
$robots_table .= '|-----|----------|-----------------------|----------|------------------|-------------|'."\n";
|
||||
|
||||
foreach($robots as $robot => $details) {
|
||||
$robots_txt .= 'User-agent: '.$robot."\n";
|
||||
$robots_table .= '| '.$robot.' | '.$details['operator'].' | '.$details['respect'].' | '.$details['function'].' | '.$details['frequency'].' | '.$details['description'].' | '."\n";
|
||||
}
|
||||
|
||||
$robots_txt .= 'Disallow: /';
|
||||
|
||||
file_put_contents('robots.txt', $robots_txt);
|
||||
file_put_contents('table-of-bot-metrics.md', $robots_table);
|
Loading…
Add table
Add a link
Reference in a new issue