Refresh GitHub data #100
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Refresh GitHub data | |
| on: | |
| schedule: | |
| # Cada dos horas y no una vez al dia. El numero se movia de a decenas entre | |
| # corridas y en la pagina quedaba viejo al lado del perfil de GitHub: 5.006 | |
| # contra 5.018 el mismo dia. | |
| # Minuto 17 y no en punto: a las horas exactas la cola de Actions esta | |
| # llena y los cron programados arrancan varios minutos tarde. | |
| - cron: "17 */2 * * *" | |
| workflow_dispatch: | |
| push: | |
| branches: [main] | |
| paths: | |
| - scripts/fetch_github.py | |
| - .github/workflows/refresh-data.yml | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: refresh-data | |
| cancel-in-progress: true | |
| jobs: | |
| refresh: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Fetch contributions and repos | |
| # PROFILE_TOKEN is a personal access token with `read:user`, so the | |
| # calendar total includes private contributions. Without it the job | |
| # still runs, it just reports public activity only. | |
| env: | |
| GH_TOKEN: ${{ secrets.PROFILE_TOKEN || github.token }} | |
| run: python scripts/fetch_github.py | |
| # 🔴 Generar ANTES de commitear. `index.html` y `en/index.html` salen de | |
| # `src/index.html`, y adentro va el numero de contribuciones: sin este | |
| # paso, el refresco de datos publica las paginas de la corrida anterior y | |
| # el numero del html se queda viejo aunque el JSON se actualice. | |
| - name: Armar las paginas | |
| run: python scripts/armar.py | |
| - name: Commit if changed | |
| run: | | |
| # index.html tambien: adentro va el numero de respaldo, el que se | |
| # ve mientras el JSON no llego y el unico que se ve si la peticion | |
| # falla. Escrito a mano envejece en silencio. | |
| # | |
| # ⚠️ Las carpetas de servicio salen del propio json y no escritas a | |
| # mano: agregar un servicio septimo no tiene que acordarse de tocar | |
| # este archivo tambien. Lo que no este en esta lista se genera, queda | |
| # sucio en el runner y nunca se publica. | |
| SRV=$(python -c "import json;print(' '.join(s['ruta']+'/' for s in json.load(open('contenido/servicios.json',encoding='utf-8'))))") | |
| RUTAS="data/github.json index.html en/ sitemap.xml llms.txt $SRV" | |
| if [ -z "$(git status --porcelain $RUTAS)" ]; then | |
| echo "no change" | |
| exit 0 | |
| fi | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add $RUTAS | |
| git commit -m "chore(data): refresh GitHub activity" | |
| git push |