# Set Up GitHub Actions CI for a Pulumi Project

Yes. An agent adds a GitHub Actions workflow that runs pulumi preview on pull requests and pulumi up on main for your Pulumi project, checks it, and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/add-github-actions-ci/pulumi/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads the project before it writes a workflow, because the steps depend on the runtime, the package manager and the config the program needs. In a project shaped like the `aws-ts-s3-folder` example in pulumi/examples, `Pulumi.yaml` declares `runtime: nodejs` and a template config with `aws:region` defaulting to `us-west-2`; `package.json` pins `@pulumi/pulumi` 3.228.0, `@pulumi/aws` 7.23.0 and `mime`, with `typescript` and `ts-node` as dev dependencies and `"type": "module"`; `tsconfig.json` compiles only `index.ts` with `ts-node` in ESM mode; and `index.ts` creates an `aws.s3.Bucket`, a `BucketWebsiteConfiguration`, a `BucketPublicAccessBlock`, one `BucketObject` per file in `www/`, and a `BucketPolicy`, exporting `bucketName` and `websiteUrl`. The project has no workflow of its own: the examples repository tests it through a Go acceptance suite in `misc/test` and a `scripts/pr-preview-changed.sh` script that runs `pulumi preview` on a temporary file backend for the examples a pull request touched, which is not something a project copied out of that repository carries with it.

The agent adds `.github/workflows/pulumi.yml` with two jobs. `preview` runs on `pull_request`: it checks out the code, sets up Node with `npm` caching, runs `npm ci`, installs the CLI with `pulumi/actions`' `install` command, and runs `pulumi/actions` with `command: preview`, `stack-name` from a workflow variable, and `comment-on-pr: true` so the resource diff lands on the pull request. `up` runs on `push` to `main` with the same setup and `command: up`, guarded by a GitHub environment so a reviewer can require approval before anything is applied. Both jobs authenticate to AWS with `aws-actions/configure-aws-credentials` using OIDC and a role ARN from a repository variable, with `permissions: id-token: write` and `contents: read`, so no long-lived AWS key is stored; the Pulumi access token comes from a `PULUMI_ACCESS_TOKEN` secret, and the region is set with `pulumi config set aws:region` from the template default in `Pulumi.yaml`.

A workflow that has never run is not evidence, so the agent runs the same steps in the sandbox before it opens the pull request: `npm ci`, `pulumi login --local` against a file backend, `pulumi stack init ci-check`, `pulumi config set aws:region us-west-2`, and `pulumi preview` with the AWS provider pointed at placeholder credentials and `skip-credentials-validation`, which exercises the program, the TypeScript compilation and the resource graph without reaching AWS. It also runs `actionlint` over the new file. The preview output listing the bucket, the website configuration, the public access block, the two objects from `www/` and the policy goes into the description.

The agent adds a README section on what the workflow needs from the repository: the `PULUMI_ACCESS_TOKEN` secret, the `AWS_ROLE_ARN` and `PULUMI_STACK` variables, and the trust policy the IAM role needs for GitHub's OIDC provider, with the exact `sub` claim pattern for this repository and branch. It pushes one commit for the workflow and one for the README.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add GitHub Actions CI to this Pulumi project and open a pull request. Read Pulumi.yaml, package.json, tsconfig.json, index.ts, README.md and the contents of www first, and say which runtime, package manager and config the program needs. Add .github/workflows/pulumi.yml with a preview job on pull_request that installs dependencies with npm ci, installs the Pulumi CLI with pulumi/actions, runs pulumi preview with comment-on-pr, and an up job on push to main under a GitHub environment, both authenticating to AWS with aws-actions/configure-aws-credentials over OIDC using a role ARN from a repository variable, the Pulumi access token from a secret, and the region from Pulumi.yaml. Before opening the pull request, run npm ci, log in to a local file backend, init a stack, set the region, and run pulumi preview with placeholder AWS credentials and skip-credentials-validation so the program and resource graph are exercised, run actionlint on the workflow, and paste both outputs in the pull request. Add a README section listing the secret, the variables and the IAM trust policy the role needs. Do not change index.ts or any resource.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request with one new file, `.github/workflows/pulumi.yml`, and a README section; `index.ts`, `Pulumi.yaml` and `package.json` are unchanged. The description shows the sandbox `pulumi preview` against the local backend with the resources the program would create, the `actionlint` result, and the list of repository settings the workflow expects, with the OIDC `sub` pattern spelled out.

Once the secret and variables are in place, the `preview` job runs on the pull request itself and comments the diff, which is the first real check. A reviewer reads that comment, confirms the `up` job is gated by the environment they want to approve, that the role's trust policy limits the claim to this repository, and that no AWS key is stored anywhere. Then they merge, and the `up` job on `main` waits for the environment approval before it applies.

## Run it on every new Pulumi project

A platform team that keeps one Pulumi project per service starts one run per repository with `POST /o/{org}/sessions`, this prompt and the repository in `resources`. The agent reads each project's own `Pulumi.yaml` and manifests, so a Python or Go project gets the matching setup steps instead of `npm ci`, and each run opens its own pull request.

The key's `webhook_url` receives `run.completed` for each run it starts, with a `session_url` to read the pull request link. A `request_id`, a UUID, in the body makes a retried start return the run already started instead of a second pull request.

## Why run it on Rush?

A CI workflow for infrastructure code is written once and then trusted with real resources, so the first version should be checked by something other than a green YAML linter. In a Rush sandbox the agent installs the Pulumi CLI, runs the program against a local backend and reads the preview itself, and keeps that output in the transcript, so the pull request shows the resource graph the workflow will preview on every pull request rather than a file that has never executed.

It is also work to hand off from the terminal: start it, and come back to a pull request that already lists the secret, the variables and the IAM trust policy to set up. The same request runs across every Pulumi project the team owns, each in its own sandbox, with the evidence kept beside each result.

## Frequently asked questions

### Why OIDC instead of AWS access keys in secrets?

Because `aws-actions/configure-aws-credentials` can exchange GitHub's OIDC token for short-lived credentials on a role whose trust policy names this repository, so nothing long-lived is stored and a leaked workflow log exposes nothing reusable. The README section the agent writes includes the trust policy and the `sub` claim pattern for the repository.

### Does the preview on a pull request touch my AWS account?

It reads: `pulumi preview` refreshes nothing by default and plans against the stack's last state, calling AWS only to validate the provider. The `up` job is the one that changes resources, and it runs only on `main` behind the GitHub environment, so a required reviewer can approve each apply.

### How does the agent test a workflow without running it on GitHub?

It runs the same commands in the sandbox against a local file backend with placeholder credentials and `skip-credentials-validation`, which compiles the TypeScript and builds the resource graph without reaching AWS, and runs `actionlint` on the YAML. The first real run is the `preview` job on the pull request itself once the secret and variables exist.

### What if my project uses Python or Go?

The prompt tells the agent to read `Pulumi.yaml` first. For `runtime: python` the setup steps become a virtual environment and `pip install -r requirements.txt`; for `go`, `actions/setup-go` and a module download. The `pulumi/actions` steps and the OIDC setup are the same.

## More Pulumi jobs

- [Add a Policy Pack to a Pulumi Program](https://getrush.ai/run/add-policy-pack/pulumi/)
- [Post Pulumi Previews on Pull Requests](https://getrush.ai/run/add-preview-comments-to-pr/pulumi/)
- [Tag Every Resource in a Pulumi Program](https://getrush.ai/run/add-resource-tags/pulumi/)

## The same job on other stacks

- [Set Up GitHub Actions CI for a React Native App](https://getrush.ai/run/add-github-actions-ci/react-native/)
- [Set Up GitHub Actions CI for a React Router App](https://getrush.ai/run/add-github-actions-ci/react-router/)
- [Add GitHub Actions CI to a Rocket App](https://getrush.ai/run/add-github-actions-ci/rocket/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
