Skip to content

ci: add OIDC-based AWS deploy workflow - #448

Merged
haseebrabbani merged 2 commits into
mainfrom
282-aws-deploy-workflow
Sep 8, 2026
Merged

haseebrabbani merged 2 commits into
mainfrom
282-aws-deploy-workflow

Conversation

@haseebrabbani

Copy link
Copy Markdown
Collaborator

Closes #282.

Adds a workflow_dispatch workflow that deploys a published ghcr.io/openzeppelin/guardian release image to the stg or prod ECS stack, using GitHub OIDC role chaining only — no long-lived AWS keys.

How it works

  • Inputs: environment (stg/prod) and version (e.g. v1.2.3; prod refuses pre-releases).
  • A validate job resolves the tag to an immutable digest and verifies that digest against the SLSA provenance attestation signed by docker-publish.yml; prod additionally requires the build to have run from refs/tags/<version>, so a manually dispatched build of another branch cannot ship to prod under a release version. This runs before environment protection rules, so prod reviewers only approve an already-verified digest.
  • The deploy job (GitHub environment stg/prod) authenticates via OIDC, checks the ECR repo and ECS service exist, mirrors the verified digest into <stack>-server tagged both <version> and latest, registers a new revision of the task definition the service is currently running with only the image changed, and waits for stability.
  • Moving ECR latest keeps scripts/aws-deploy.sh plan / deploy --skip-build resolving the deployed image, so a later Terraform apply does not roll the service back.
  • The run summary always records the deployed image and previous task-definition ARN, and prints the rollback command on failure.

Required setup (infra)

  • GitHub environments stg and prod with variables AWS_REGION, ROLE_FOR_OIDC, ROLE_TO_ASSUME, STACK_NAME (guardian / guardian-prod); required reviewers on prod recommended.
  • OIDC role trust policy extended to repo:OpenZeppelin/guardian:environment:stg|prod.
  • Deploy role permissions are listed in docs/SERVER_AWS_DEPLOY.md.

Notes

  • Image-only rollouts: when a release also changes the task definition (env vars, secrets, IAM grants), apply that release's infra/ first, then deploy the image.
  • guardian-evm is out of scope: GHCR release images are built with features=postgres only.
  • Follow-up worth filing: deployment_circuit_breaker { enable = true, rollback = true } on the ECS service so a bad image fails fast instead of timing out the 20-minute wait.
  • Docs updated: docs/SERVER_AWS_DEPLOY.md (new section), infra/README.md (pointer).

Adds a workflow_dispatch deploy of a published ghcr release image to the
stg or prod ECS stack: verify build provenance, mirror the image into the
environment's ECR repository, and roll the service to a new task
definition revision. AWS access uses GitHub OIDC role chaining only.

Refs #282
@coderabbitai

coderabbitai Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 0cf15b76-fdba-4705-8335-43addf01031b


Comment @coderabbitai help to get the list of available commands.

@zeljkoX zeljkoX left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Few nits:

  • The validate job needs attestations: read. Because the workflow declares explicit permissions, gh attestation verify may otherwise fail when retrieving attestations through the GitHub API.
  • Both deployment environments must restrict deployment branches to main. A manually dispatched workflow can otherwise run an edited workflow definition from a feature branch and obtain the environment-scoped AWS OIDC identity.

Comment thread docs/SERVER_AWS_DEPLOY.md Outdated
published GHCR version to the `stg` or `prod` stack without local AWS
credentials or Terraform state. Run it from the Actions tab with:

- `environment`: `stg` or `prod`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we name the GitHub environments after their target networks? devnet, testnet, and eventually mainnet and map each one to the existing AWS resources through environment variables? For example, testnet can keep its stack name, so this does not require renaming the current stack. The infrastructure profile and network remain explicit internal settings rather than being inferred from the environment name.

Address review: GitHub environments are devnet/testnet (mainnet later)
and map onto stacks via STACK_NAME; only devnet accepts pre-releases.
The validate job needs attestations:read for gh attestation verify
under the explicit permissions block. Document that each environment
must restrict deployment branches to main.

@zeljkoX zeljkoX left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@haseebrabbani
haseebrabbani merged commit 54035bf into main Sep 8, 2026
26 checks passed
@haseebrabbani
haseebrabbani deleted the 282-aws-deploy-workflow branch September 8, 2026 13:04
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: Deploy Guardian server to AWS from a GitHub Actions workflow

2 participants