Skip to content

lfreleng-actions/gerrit-review-action

Repository files navigation

🔍 Gerrit Review Action

Set review votes and comments on a Gerrit system via SSH. This action allows automated CI/CD workflows to provide feedback on Gerrit changes by posting votes, comments, and status updates.

gerrit-review-action

Usage Example

steps:
  - name: "Set Gerrit review vote"
    uses: lfreleng-actions/gerrit-review-action@main
    with:
      host: "gerrit.example.com"
      username: "ci-bot"
      key: ${{ secrets.GERRIT_SSH_KEY }}
      known_hosts: ${{ secrets.GERRIT_KNOWN_HOSTS }}
      gerrit-change-number: "12345"
      gerrit-patchset-number: "1"
      vote-type: "success"

Inputs

Name Required Default Description
host True The Gerrit host with SSH available
port False "29418" The SSH port to use
username True The username to connect to the Gerrit host as
key True The SSH private key to use
key_name False "id_rsa" The filename for the key
known_hosts True The known hosts for the host server
gerrit-change-number True The Gerrit Change Number to vote on
gerrit-patchset-number False "1" The patchset number of the change
vote-type False "clear" Vote type: clear, success, failure, cancelled
comment-only False "false" Post comment without voting

Outputs

This action does not produce any outputs.

Vote Types

The action supports four different vote types:

clear

  • Vote: Verified=0, Code-Review=0
  • Usage: Reset/clear existing votes on a change
  • Status Message: "STARTED"

success

  • Vote: Verified=+1
  • Usage: Mark the change as verified/passing
  • Status Message: "SUCCESS"

failure

  • Vote: Verified=-1
  • Usage: Mark the change as failing verification
  • Status Message: "FAILURE"

cancelled

  • Vote: Verified=-1, Code-Review=-1
  • Usage: Mark the workflow run as cancelled/aborted (inconclusive result)
  • Status Message: "CANCELLED"

Comment Mode

When comment-only is "true", the action posts a status comment without applying votes. This provides informational updates without affecting the review workflow.

SSH Configuration

The action requires SSH access to the Gerrit server. You must provide:

  1. SSH Private Key: Store in GitHub secrets (e.g., GERRIT_SSH_KEY)
  2. Known Hosts: The SSH fingerprint for the Gerrit server
  3. Username: The Gerrit username for the CI account
  4. Host: The Gerrit server hostname

The action automatically configures SSH with the provided credentials and accepts legacy SSH-RSA key types for compatibility with Gerrit servers.

Implementation Details

The action performs the following steps:

  1. SSH Setup: Installs the provided SSH key and configures connection
  2. Vote Preparation: Determines the appropriate vote and status based on the vote-type input
  3. Gerrit Review: Executes the gerrit review command with:
    • Change and patchset numbers
    • Appropriate vote labels (if not comment mode)
    • Status message with GitHub Actions run URL
    • autogenerated:github tag for tracking

Status Messages

All reviews include a status message linking back to the GitHub Actions run:

{STATUS}: https://github.com/{owner}/{repo}/actions/runs/{run_id}

This provides traceability between Gerrit reviews and the CI/CD pipeline that generated them.

Notes

  • The action skips SSH operations when running in ACT (local testing)
  • All reviews include the autogenerated:github tag for identification
  • The action supports both legacy and modern SSH key types
  • Default SSH port 29418 is commonly used by Gerrit servers

About

GitHub Action for doing reviews on Gerrit systems

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors