Repository navigation
CI: publicar as tabelas IBPT no R2 via GitHub Actions - #6
Merged
Merged
Conversation
- push to master touching lc116/, nbs/, ncm/, the map or the script runs publish-r2.js --apply (only what changed is uploaded) - pull requests run the dry-run, with the result in the job summary - manual runs are dry-run by default, with apply and allow_mass_delete options - one publish at a time (concurrency group, no cancel) - needs the R2_ACCOUNT_ID, R2_ACCESS_KEY_ID and R2_SECRET_ACCESS_KEY secrets; without them the PR dry-run is skipped with a warning and push fails publish-r2.js fixes the gzip header OS byte to 255, so the md5/etag is the same on linux (CI) and windows; package-lock.json added for npm ci. Refs #2 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015op3Yt7XX876JEcM3LhWJT
The v4 actions target the deprecated Node 20 runtime and GitHub already warns that they are being forced to Node 24. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015op3Yt7XX876JEcM3LhWJT
sergiojrdotnet
requested review from
sergiojrdotnet
and
a balanced review from Copilot
September 29, 2026 18:47
sergiojrdotnet
approved these changes
Sep 29, 2026
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Write credentials are exposed to PR-controlled code, and shared concurrency can discard a pending production publication.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Automatiza a publicação das tabelas IBPT no Cloudflare R2 via GitHub Actions.
Changes:
- Adiciona workflow para simulação e publicação.
- Torna o gzip consistente entre sistemas operacionais.
- Documenta o fluxo e fixa dependências com lockfile.
| File | Description |
|---|---|
.github/workflows/publish.yml |
Configura publicação e simulação no CI. |
publish-r2.js |
Normaliza o byte de SO do gzip. |
package-lock.json |
Permite instalações reproduzíveis com npm ci. |
docs/atualizacao-tabela-ibpt.md |
Documenta o fluxo automatizado. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Review findings on the publish workflow: - pull requests from branches of this repository received the write token and ran PR-controlled code (package.json, script, workflow). The publish job now runs in the 'production' environment, whose secrets are restricted to master, and dry-runs (PR and manual without apply) use a separate Object Read only token (R2_READONLY_ACCESS_KEY_ID / R2_READONLY_SECRET_ACCESS_KEY) - a dry-run sharing the concurrency group could replace a pending publish. Concurrency is now per job: publishes share publish-ibpt (no cancel), dry-runs use a per-ref group Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015op3Yt7XX876JEcM3LhWJT
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Refs #2
Motivação
Sugestão do Sérgio: como este repositório serve só para as tabelas IBPT, o push na
masterjá deve publicar emhttps://ibpt.nfe.io(bucket R2ibpt), sem depender de alguém rodar opublish-r2.jsna própria máquina.Mudanças
.github/workflows/publish.yml(Publish IBPT tables), com dois jobs:publish: rodapublish-r2.js --apply, que publica só o que mudou.masterque alterelc116/,nbs/,ncm/,lc116-nbs-map.json, o script ou o workflow.apply, que só é aceita namaster.production, o único lugar onde fica o token de escrita.concurrencypublish-ibpt, sem cancelamento, então duas publicações nunca rodam juntas.dry-run: simulação, com o resultado no resumo do job.apply.concurrencypor branch, então nunca substitui uma publicação pendente.tables,applyeallow_mass_delete. A última serve para quando uma versão nova do IBPT remove mais de 25% de uma tabela.permissions: contents: read;tablesé validado pelo script contralc116/nbs/ncm;productionsó libera os secrets para amaster. Veja o review do Copilot.publish-r2.js: fixa o byte de SO do cabeçalho gzip em 255. Antes o Linux gerava 3 e o Windows 10, então o CI via como alterado tudo o que tinha sido publicado do Windows. Agora o ETag é o mesmo em qualquer máquina.package-lock.json: adicionado, para o CI usarnpm ci.docs/atualizacao-tabela-ibpt.md: fluxo com o Action, credenciais e execução manual.Configuração necessária (admin)
ibpt)R2_ACCOUNT_IDR2_READONLY_ACCESS_KEY_ID,R2_READONLY_SECRET_ACCESS_KEYproductionR2_ACCESS_KEY_ID,R2_SECRET_ACCESS_KEYproductionprecisa estar com Deployment branches and tags → Selected branches →master.R2_ACCESS_KEY_ID/R2_SECRET_ACCESS_KEYnão devem existir como secrets do repositório.Validação
actionlint1.7.7 sem erros.A lógica de cada job foi testada com um
nodefalso:publishem push--applypublishmanual, ncm, mass delete--tables ncm --apply --allow-mass-deletepublishsem secretsdry-runem PR--applydry-runmanual--tables lc116dry-runsem secretsAntes da separação de credenciais, uma simulação real contra o bucket confirmou o estado publicado em 29/09:
lc116:remote=5512,delete=0, incluindo os 2 manuais de RJ protegidos;nbs:remote=23220,delete=0.O gzip com o byte fixado descompacta idêntico ao arquivo original.
CodeQL sem alertas.
publishfalha, e depois de configurar basta fazer re-run.🤖 Generated with Claude Code
https://claude.ai/code/session_015op3Yt7XX876JEcM3LhWJT