|
| 1 | +# moon-raa |
| 2 | + |
| 3 | +Manage review apps and artifacts (RAA) for a Moon monorepo. Creates GitHub Deployments, runs per-project build/teardown tasks, and produces a manifest of artifacts. |
| 4 | + |
| 5 | +## Usage |
| 6 | + |
| 7 | +```yaml |
| 8 | +- uses: ./.github/actions/moon-raa |
| 9 | + with: |
| 10 | + command: run # or rm |
| 11 | + pr-number: ${{ inputs.pr-number }} |
| 12 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 13 | +``` |
| 14 | +
|
| 15 | +## Inputs |
| 16 | +
|
| 17 | +| Input | Required | Default | Description | |
| 18 | +| -------------- | -------- | ------- | --------------------------------------------------------- | |
| 19 | +| `command` | yes | | `run` to build review artifacts, `rm` to tear down | |
| 20 | +| `pr-number` | yes | | PR number | |
| 21 | +| `prefix` | no | `raa` | Environment name prefix (produces `<prefix>-pr-<number>`) | |
| 22 | +| `github-token` | yes | | `GITHUB_TOKEN` for deployment API calls | |
| 23 | + |
| 24 | +## Outputs |
| 25 | + |
| 26 | +| Output | Command | Description | |
| 27 | +| --------------- | ------- | --------------------------------------------- | |
| 28 | +| `deployment-id` | run | GitHub Deployment ID | |
| 29 | +| `environment` | both | Environment name (e.g. `raa-pr-42`) | |
| 30 | +| `project-count` | both | Number of projects processed | |
| 31 | +| `summary` | both | Markdown summary for `GITHUB_STEP_SUMMARY` | |
| 32 | +| `manifest` | run | Full payload as JSON | |
| 33 | +| `clean` | rm | `true` if teardown completed without warnings | |
| 34 | + |
| 35 | +## Project Configuration |
| 36 | + |
| 37 | +The action discovers affected projects via `moon query projects --affected` and filters to those with `raa` metadata in their `moon.yml`. |
| 38 | + |
| 39 | +Both `run` and `rm` fields are required. Projects missing either field are skipped with a warning. |
| 40 | + |
| 41 | +```yaml |
| 42 | +# plugins/my-plugin/moon.yml |
| 43 | +project: |
| 44 | + metadata: |
| 45 | + raa: |
| 46 | + run: review # task to run for review build |
| 47 | + rm: review-rm # task to run for teardown |
| 48 | +``` |
| 49 | + |
| 50 | +The action executes `moon run <project-id>:<raa.run>` during `command: run` and `moon run <project-id>:<raa.rm>` during `command: rm`. |
| 51 | + |
| 52 | +## Workflow Integration |
| 53 | + |
| 54 | +RAA is dispatched from `pr.yml` via `raa.yml`: |
| 55 | + |
| 56 | +1. PR push triggers `pr.yml`, which runs full CI. |
| 57 | +2. After the gate passes, if the `review-app` label is present, `pr.yml` dispatches `raa.yml` with `command: run`. |
| 58 | +3. On PR close, `pr.yml` dispatches `raa.yml` with `command: rm`. |
| 59 | +4. `raa.yml` can also be triggered manually from the Actions tab. |
| 60 | + |
| 61 | +## How It Works |
| 62 | + |
| 63 | +**`run` command:** |
| 64 | + |
| 65 | +1. Discovers affected projects with valid `raa` metadata. |
| 66 | +2. Deactivates any existing deployments for the environment. |
| 67 | +3. Creates a new GitHub Deployment. |
| 68 | +4. Runs each project's `raa.run` task sequentially. |
| 69 | +5. Sets deployment status to `success` or `failure`. |
| 70 | + |
| 71 | +**`rm` command:** |
| 72 | + |
| 73 | +1. Reads the deployment manifest to find projects. |
| 74 | +2. Runs each project's `raa.rm` task. |
| 75 | +3. Deactivates and deletes the deployment. |
| 76 | +4. Deletes the GitHub environment. |
0 commit comments