Skip to content

Commit

Permalink
feat: add index rebuild workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Erick2280 committed Feb 17, 2025
1 parent d0a3c1d commit 775170d
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 1 deletion.
54 changes: 54 additions & 0 deletions .github/workflows/index-rebuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: index-rebuild

on:
workflow_dispatch:

jobs:
scrape:
runs-on: ubuntu-latest

steps:
- name: Use Deno v2.x
uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- name: Generate bot token
uses: actions/create-github-app-token@v1
id: maicon-token
with:
app-id: ${{ vars.MAICON_BOT_CLIENT_ID }}
private-key: ${{ secrets.MAICON_BOT_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: |
scraper
archive
- name: Checkout scraper repo
uses: actions/checkout@v4
with:
ref: production
token: ${{ steps.maicon-token.outputs.token }}

- name: Checkout archive repo
uses: actions/checkout@v4
with:
repository: rusbeapp/archive
ref: main
path: ./dist
token: ${{ steps.maicon-token.outputs.token }}

- name: Run scraper to rebuild index
run: |
deno task index-rebuild
env:
CI: true

- name: Commit updates to archive repo
run: |
git config --global user.name "MaiconBot[bot]"
git config --global user.email "191420508+maiconbot[bot]@users.noreply.github.com"
git -C ./dist add .
git -C ./dist diff-index --quiet HEAD || git -C ./dist commit -m "chore: update archive index"
git -C ./dist push
3 changes: 2 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"tasks": {
"dev": "deno run --unsafely-ignore-certificate-errors=www.ufpe.br --watch src/main.ts",
"start": "deno run --allow-net=www.ufpe.br --allow-write --allow-read --unsafely-ignore-certificate-errors=www.ufpe.br src/main.ts"
"start": "deno run --allow-net=www.ufpe.br --allow-write --allow-read --unsafely-ignore-certificate-errors=www.ufpe.br src/main.ts",
"index-rebuild": "deno run --allow-write --allow-read src/index-rebuild.ts"
}
}
8 changes: 8 additions & 0 deletions src/index-rebuild.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { CURRENT_SCRAPER_VERSION } from './constants.ts';
import { saveScrapingOutput } from './file-management.ts';

console.log(`${CURRENT_SCRAPER_VERSION} - Starting index rebuild`)

saveScrapingOutput([]);

console.log(`${CURRENT_SCRAPER_VERSION} - Finished index rebuild`);
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,5 @@ for (const section of operationDaySections) {
console.log(`${CURRENT_SCRAPER_VERSION} - Scraping finished, ${operationDays.length} days found`);

saveScrapingOutput(operationDays);

console.log(`${CURRENT_SCRAPER_VERSION} - Finished`);

0 comments on commit 775170d

Please sign in to comment.