Skip to content
← Inforjota
Cursos Inforjota Português

Lesson 2 of 6 · 15 min · Checked on 10 October 2026

CI/CD with agents: GitHub Actions and PR review

By the end of this lesson you will be able to:

  • Explain what continuous integration is and what it is for in a small project
  • Create a minimal GitHub Actions workflow that runs pytest on every change
  • Connect Claude's or Codex's pull request review, with the key stored as a secret
  • Protect the main branch so the agent comments and only a person approves

The junta de freguesia (parish council) has a small program for bookings of the multi-purpose hall. On a Friday, Pedro, who helps in his spare time, changed one line to fix a date and sent it to GitHub. On Saturday nobody could book anything. The tests existed and would have caught the mistake. But nobody ran them.

The concept: a machine that runs the tests for you

Continuous integration (CI) means this: every time someone sends a change, a separate machine downloads the project, installs what it needs and runs the tests. On the pull request you see a green tick or a red cross. Nobody forgets, because nobody has to remember.

Continuous delivery (the CD) is the next step: publishing by itself when the tests pass. That waits until you trust your tests.

Agents plug into the same mechanism. Instead of only running tests, the machine calls an agent that reads the pull request and leaves comments. The rule of this lesson is simple: the agent comments, the person decides.

How it is done today: the first workflow

This is how it looks on 6 October 2026; your screen may differ. Look for the button with the same name. Guide: docs.github.com/en/actions/tutorials/build-and-test-code/python.

In the project from lesson 2/07, create the file .github/workflows/testes.yml (testes is Portuguese for “tests”):

name: Testes
on: [push, pull_request]
jobs:
  testes:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-python@v5
        with:
          python-version: '3.x'
      - name: Instalar
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt
      - name: Test with pytest
        run: pytest

Read it from top to bottom: it runs on every push and every pull request, on a Linux machine from GitHub, and gives up after 10 minutes. The steps download the code, install Python and the dependencies, and run pytest. The requirements.txt has to include pytest.

Tip

Ask the agent to write the workflow, but compare it with the official guide before the commit. Version numbers (@v6, @v5) change over time and the agent may remember old numbers.

The key stays in a secret

In the repository, open Settings. In the “Security” section of the sidebar, choose Secrets and variables and then Actions. Click New repository secret, name it ANTHROPIC_API_KEY (or OPENAI_API_KEY), paste the value and confirm with Add secret.

Watch out

The key never goes into the .yml file, not even in a private repository. The workflow only refers to it by name, as ${{ secrets.ANTHROPIC_API_KEY }}. Create a key just for this repository, so you can see its usage separately and revoke it without touching anything else (lesson 1/06).

PR review with Claude

The official integration is called Claude Code GitHub Actions and uses the action anthropics/claude-code-action@v1. Guide: code.claude.com/docs/en/github-actions.

The quick way: open claude inside the repository and run /install-github-app. It installs the GitHub app, saves the secret and prepares the workflow in a pull request. You need to be an administrator of the repository, and it only works with repositories on github.com.

The manual way: install the Claude GitHub app, create the secret and copy the example file claude.yml, linked in the guide, into .github/workflows/. From then on, you write @claude in a PR comment and it answers. The guide also has a workflow that reviews every open PR on its own.

The Codex equivalent

The official action is openai/codex-action@v1, with the key in openai-api-key: ${{ secrets.OPENAI_API_KEY }} and the request in a file, for example .github/codex/prompts/review.md. The official example separates the jobs: Codex only reads the code, and another step, with permission to write comments, publishes the answer. Guide: learn.chatgpt.com/docs/github-action.

The house rules

  • Never give the agent merge permission in a real project. It proposes and comments; a person approves.
  • Protect the main branch. In Settings, in the “Code, planning, and automation” section, choose Branches and then Add classic branch protection rule. Turn on Require a pull request before merging and Require status checks to pass before merging, and pick your test in the search field that appears. If there are more people on the project, also turn on Require approvals. By default, whoever administers the repository can bypass the rule; the guide shows how to apply it to administrators too.
  • The text of a PR is data, not instruction. A PR can carry sentences written to trick the agent (lesson 2/04). Both actions only accept requests from people with write access to the repository, and the Codex guide recommends cleaning the text before giving it to the model.

What each run costs

Each run spends GitHub Actions minutes and model tokens. Three controls help: run the review only when a PR is opened or updated, not on every push; the timeout-minutes setting; and, in Claude, --max-turns on the claude_args line. The brake for the month is still the spending limit in the provider's console. Amounts change: see the Current state page.

Tip

Start with the tests only. Add the agent's review when the green tick is already routine; that way you know whether a red cross comes from the code or from the agent.

Exercise

How I know it worked the first push shows a green tick on the PR, the second a red cross, and the merge button stays blocked while the test fails.

If it didn't work

  • Nothing shows up in the Actions tab: check the path .github/workflows/ and the .yml extension.
  • pytest: command not found: pytest is missing from requirements.txt.
  • The agent does not answer @claude: check the name of the secret, that the app is installed on the repository, and that the person who commented has write access.
  • The status check search does not find your test: send a change so the workflow runs, and search again by the job name (testes).

Videos

Criando um Workflow AUTOMATIZADO de CI com o Github Actions
Fernanda Kipper · 14 min · PT-BR · subtitles · Watch on YouTube
Builds a continuous integration workflow in GitHub Actions: install dependencies, build and run the tests on every change. It is from 2023; the agent part is in the OpenAI video.
Automatic code reviews with OpenAI Codex
OpenAI · 8 min · EN · subtitles · Watch on YouTube
An official OpenAI video: set up Codex to review pull requests automatically in GitHub and in the CLI, and customise the review with AGENTS.md.

Test what you learned

1. You want the agent to review the pull requests of the junta's project. Which permissions do you give it?
2. A colleague suggests putting the API key straight into the workflow's .yml file, “because the repository is private”. What do you answer?
3. The automatic review runs on every push and the month's spending went up more than you expected. What is the best reaction?

Corrections to this lesson (1)
  • : Second external review: in branch protection, also turn on «Do not allow bypassing the above settings».