cpflow 5.0.0 → 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.claude/commands/update-changelog.md +88 -23
  3. data/.github/actions/cpflow-resolve-review-config/action.yml +137 -0
  4. data/.github/actions/cpflow-setup-environment/action.yml +118 -0
  5. data/.github/workflows/cpflow-cleanup-stale-review-apps.yml +26 -21
  6. data/.github/workflows/cpflow-delete-review-app.yml +21 -18
  7. data/.github/workflows/cpflow-deploy-review-app.yml +23 -19
  8. data/.github/workflows/cpflow-deploy-staging.yml +15 -11
  9. data/.github/workflows/cpflow-help-command.yml +0 -6
  10. data/.github/workflows/cpflow-promote-staging-to-production.yml +30 -5
  11. data/.github/workflows/cpflow-review-app-help.yml +1 -10
  12. data/CHANGELOG.md +32 -1
  13. data/Gemfile.lock +1 -1
  14. data/docs/ai-github-flow-prompt.md +1 -1
  15. data/docs/ci-automation.md +215 -29
  16. data/docs/commands.md +1 -1
  17. data/lib/command/ai_github_flow_prompt.rb +1 -1
  18. data/lib/command/run.rb +11 -1
  19. data/lib/command/setup_app.rb +1 -1
  20. data/lib/cpflow/version.rb +1 -1
  21. data/lib/generator_templates/Dockerfile +9 -3
  22. data/lib/generator_templates/entrypoint.sh +42 -2
  23. data/lib/generator_templates/templates/app.yml +3 -3
  24. data/lib/generator_templates/templates/postgres.yml +19 -16
  25. data/lib/generator_templates/templates/rails.yml +3 -1
  26. data/lib/generator_templates_sqlite/templates/app.yml +3 -3
  27. data/lib/generator_templates_sqlite/templates/rails.yml +3 -1
  28. data/lib/github_flow_templates/.github/cpflow-help.md +95 -79
  29. data/lib/github_flow_templates/.github/workflows/cpflow-cleanup-stale-review-apps.yml +4 -9
  30. data/lib/github_flow_templates/.github/workflows/cpflow-delete-review-app.yml +2 -9
  31. data/lib/github_flow_templates/.github/workflows/cpflow-deploy-review-app.yml +3 -9
  32. data/lib/github_flow_templates/.github/workflows/cpflow-deploy-staging.yml +3 -8
  33. data/lib/github_flow_templates/.github/workflows/cpflow-help-command.yml +0 -9
  34. data/lib/github_flow_templates/.github/workflows/cpflow-promote-staging-to-production.yml +10 -8
  35. data/lib/github_flow_templates/.github/workflows/cpflow-review-app-help.yml +4 -10
  36. data/lib/github_flow_templates/bin/pin-cpflow-github-ref +3 -1
  37. data/lib/github_flow_templates/bin/test-cpflow-github-flow +23 -8
  38. metadata +2 -1
@@ -6,7 +6,7 @@ spec:
6
6
  - name: rails
7
7
  cpu: 300m
8
8
  inheritEnv: true
9
- image: {{APP_IMAGE_LINK}}
9
+ image: "{{APP_IMAGE_LINK}}"
10
10
  memory: 512Mi
11
11
  ports:
12
12
  - number: 3000
@@ -34,3 +34,5 @@ spec:
34
34
  - 0.0.0.0/0
35
35
  outboundAllowCIDR:
36
36
  - 0.0.0.0/0
37
+ # cpflow apply-template replaces {{APP_IDENTITY_LINK}} with the app workload identity link.
38
+ identityLink: "{{APP_IDENTITY_LINK}}"
@@ -1,102 +1,118 @@
1
- # Review app help
1
+ # Review App Commands
2
2
 
3
- You asked for review app help. These commands are generated by [cpflow](https://github.com/shakacode/control-plane-flow).
3
+ These commands are generated by [cpflow](https://github.com/shakacode/control-plane-flow).
4
+ For full setup, version-pinning, and troubleshooting details, see the upstream
5
+ [CI automation guide](https://github.com/shakacode/control-plane-flow/blob/__CPFLOW_GITHUB_ACTIONS_REF__/docs/ci-automation.md).
4
6
 
5
- ## PR commands
7
+ ## Pull Request Commands
6
8
 
7
- `+review-app-deploy`
8
- - Creates the review app if it does not exist
9
- - Builds the PR commit image
10
- - Deploys the image and comments with the review URL
11
- - Comment body must be exactly `+review-app-deploy`, with no surrounding text or trailing spaces. A single trailing newline from GitHub's comment editor is accepted. Comments like `please +review-app-deploy now` or `+review-app-deploy ` (with a trailing space) silently no-op.
9
+ Comment with exactly one command, with no surrounding text or trailing spaces.
10
+ A single trailing newline from GitHub's comment editor is accepted.
12
11
 
13
- `+review-app-delete`
14
- - Deletes the review app when the PR is done
15
- - This also runs automatically when the PR closes
16
- - Comment body must be exactly `+review-app-delete`, with no surrounding text or trailing spaces. A single trailing newline from GitHub's comment editor is accepted. Same command-match rule as `+review-app-deploy`.
12
+ | Command | What it does |
13
+ | --- | --- |
14
+ | `+review-app-deploy` | Builds the PR image, creates the review app if needed, deploys, and comments with the review URL. |
15
+ | `+review-app-delete` | Deletes the review app. This also runs automatically when the PR closes. |
16
+ | `+review-app-help` | Posts this help message on the PR. |
17
17
 
18
- `+review-app-help`
19
- - Posts this message on the PR.
20
- - Comment body must be exactly `+review-app-help`, with no surrounding text or trailing spaces. A single trailing newline from GitHub's comment editor is accepted. Same command-match rule as `+review-app-deploy`.
18
+ ## Standard Setup
21
19
 
22
- ## Workflow behavior
20
+ For the normal generated review-app path, GitHub needs one repository secret:
23
21
 
24
- - Review apps are opt-in and created with `+review-app-deploy`
25
- - New commits redeploy existing review apps automatically
26
- - Pushes to the staging branch deploy staging automatically
27
- - Promotion to production is manual via the Actions tab
28
- - A nightly workflow removes stale review apps
22
+ | Name | Where | Notes |
23
+ | --- | --- | --- |
24
+ | `CPLN_TOKEN_STAGING` | Repository secret | Control Plane service-account token for the staging/review org. |
29
25
 
30
- <details>
31
- <summary>Advanced: GitHub Actions secrets and variables</summary>
26
+ No repository variables are required for the standard review-app path when
27
+ `.controlplane/controlplane.yml` has exactly one review app entry with
28
+ `match_if_app_name_starts_with: true`. cpflow infers the review-app prefix and
29
+ staging org from that config.
32
30
 
33
- ### GitHub Actions secrets
31
+ Optional overrides exist for forks, clones, and unusual apps:
34
32
 
35
- | Name | Required | Notes |
36
- | --- | --- | --- |
37
- | `CPLN_TOKEN_STAGING` | yes | Service-account token scoped to the staging Control Plane org on controlplane.com. |
38
- | `CPLN_TOKEN_PRODUCTION` | yes (for promote) | Service-account token scoped to the production Control Plane org on controlplane.com. |
39
- | `DOCKER_BUILD_SSH_KEY` | optional | Private SSH key used when Docker builds fetch private deps via `RUN --mount=type=ssh`. |
33
+ | Name | Notes |
34
+ | --- | --- |
35
+ | `CPLN_ORG_STAGING` | Override the staging/review Control Plane org inferred from `controlplane.yml`. |
36
+ | `REVIEW_APP_PREFIX` | Override the review-app prefix inferred from `controlplane.yml`. |
37
+ | `PRIMARY_WORKLOAD` | Public workload used for review URLs and health checks; defaults to `rails`. |
40
38
 
41
- ### GitHub Actions variables
39
+ ## Staging And Production
42
40
 
43
- | Name | Required | Notes |
44
- | --- | --- | --- |
45
- | `CPLN_ORG_STAGING` | yes | Control Plane org on controlplane.com for staging and review apps. |
46
- | `CPLN_ORG_PRODUCTION` | yes (for promote) | Control Plane org on controlplane.com for production. |
47
- | `STAGING_APP_NAME` | yes | App name in `controlplane.yml` used as the staging deploy target. |
48
- | `PRODUCTION_APP_NAME` | yes (for promote) | App name in `controlplane.yml` used as the production deploy target. |
49
- | `REVIEW_APP_PREFIX` | yes | Prefix for per-PR review app names (e.g. `review-app`). |
50
- | `REVIEW_APP_DEPLOYING_ICON_URL` | optional | Custom image URL for the animated deploying icon in review-app PR comments. Set to `none` to use the text fallback icon. |
51
- | `STAGING_APP_BRANCH` | optional | Custom staging branch. Custom branches must also appear in `cpflow-deploy-staging.yml`'s push filter. |
52
- | `PRIMARY_WORKLOAD` | optional | Workload polled for health and rollback (defaults to `rails`). |
53
- | `DOCKER_BUILD_EXTRA_ARGS` | optional | Newline-delimited extra docker build tokens (e.g. `--build-arg=FOO=bar`). |
54
- | `DOCKER_BUILD_SSH_KNOWN_HOSTS` | optional | SSH known_hosts entries when SSH build hosts are not GitHub.com. |
55
- | `HEALTH_CHECK_ACCEPTED_STATUSES` | optional | Space-separated HTTP statuses considered healthy on promote (default `200 301 302`). |
56
- | `CPLN_CLI_VERSION` | optional | Pin a specific `@controlplane/cli` version; falls back to the action default when unset. |
57
- | `CPFLOW_VERSION` | optional | Pin a published RubyGems version such as `5.0.0`. Leave unset for normal generated workflows so the setup action builds `cpflow` from the same `control-plane-flow` GitHub ref used by the reusable workflow. |
58
-
59
- </details>
60
-
61
- <details>
62
- <summary>Advanced: testing unreleased control-plane-flow changes</summary>
63
-
64
- Generated workflow wrappers have two related pins:
65
-
66
- - The `uses: shakacode/control-plane-flow/...@<ref>` GitHub ref selects the reusable workflow code.
67
- - The `control_plane_flow_ref: <ref>` input tells the setup action which `control-plane-flow` source to check out and build when `CPFLOW_VERSION` is empty.
68
-
69
- For normal releases, point both pins at a release tag such as `v5.0.0`.
70
- You may leave `CPFLOW_VERSION` unset, or set it to the matching RubyGems version
71
- without the leading `v`, such as `5.0.0`.
72
-
73
- For temporary downstream testing of an upstream PR before a gem is released, pin
74
- both values to the exact 40-character commit SHA and leave `CPFLOW_VERSION`
75
- unset:
41
+ Staging deploys use the same `CPLN_TOKEN_STAGING` secret plus `STAGING_APP_NAME`.
42
+ Before the first staging deploy, bootstrap the persistent staging app once:
76
43
 
77
44
  ```sh
78
- bin/pin-cpflow-github-ref <40-character-control-plane-flow-commit-sha>
79
- bin/test-cpflow-github-flow ruby /path/to/control-plane-flow/bin/cpflow
45
+ cpflow setup-app -a "$STAGING_APP_NAME" --org "$CPLN_ORG_STAGING" --skip-post-creation-hook
80
46
  ```
81
47
 
82
- Do not leave downstream apps pinned to a moving branch such as `main`. A branch
83
- can pick up beta or work-in-progress changes without a downstream PR changing.
84
- Use commit SHAs for short-lived PR testing, then switch to the release tag once
85
- the gem and tag exist.
48
+ `setup-app` reads `.controlplane/controlplane.yml`'s `setup_app_templates` and
49
+ creates the app identity, app secret dictionary, app secret policy, policy
50
+ binding, and template resources. Use `--skip-post-creation-hook` so first-time
51
+ bootstrap does not try to run database setup before an image exists. For later
52
+ template updates on an existing persistent app, use `cpflow apply-template`
53
+ with the same template list and make sure the app identity has `reveal`
54
+ permission on the app secret policy.
55
+
56
+ Review apps are temporary and are created by the `+review-app-deploy` workflow,
57
+ but staging and production are persistent apps and should be bootstrapped
58
+ explicitly.
86
59
 
87
- </details>
60
+ Production promotion is part of the generated flow, but keep it protected:
61
+
62
+ | Name | Where | Notes |
63
+ | --- | --- | --- |
64
+ | `CPLN_TOKEN_PRODUCTION` | `production` GitHub Environment secret | Do not store this as a repository or organization secret. |
65
+ | `CPLN_ORG_PRODUCTION` | Prefer `production` Environment variable | Production Control Plane org. |
66
+ | `PRODUCTION_APP_NAME` | Prefer `production` Environment variable | Production app name from `controlplane.yml`. |
88
67
 
89
- <details>
90
- <summary>Advanced: testing changes to generated workflows</summary>
68
+ Configure the `production` GitHub Environment with required reviewers and
69
+ prevent self-review. The generated promotion wrapper passes only the staging
70
+ token from repository secrets; GitHub injects `CPLN_TOKEN_PRODUCTION` only after
71
+ the environment approval gate passes.
91
72
 
92
- When iterating on the generated workflow YAML on a PR branch, comment-triggered runs (`+review-app-deploy`, `+review-app-delete`, `+review-app-help`) execute the workflow code from the repository's default branch — not your PR branch. To exercise the PR-branch workflow code before merging, dispatch the workflow manually with `gh`:
73
+ Before the first promotion, bootstrap the production app the same way in the
74
+ production org, using production-only secrets and values.
75
+
76
+ ## Version Locking
77
+
78
+ Generated wrappers pin Control Plane Flow once with the reusable workflow
79
+ `uses:` ref, for example `@__CPFLOW_GITHUB_ACTIONS_REF__`. For stable releases,
80
+ this ref should be a release tag. The upstream reusable workflow automatically
81
+ loads its matching shared actions from GitHub's workflow context, so downstream
82
+ wrappers should not pass a duplicate Control Plane Flow ref input. If your
83
+ generated wrappers still include a `with:` block whose only purpose is to repeat
84
+ the same ref, regenerate them with a newer `cpflow`.
85
+
86
+ Leave `CPFLOW_VERSION` unset so the workflow builds cpflow from the same
87
+ checked-out upstream source. If you set `CPFLOW_VERSION`, it must match the
88
+ release tag, for example `CPFLOW_VERSION=5.0.1` with a wrapper pinned to
89
+ `uses: ...@v5.0.1`.
90
+
91
+ Do not leave downstream apps pinned to a moving branch such as `main`. For a
92
+ short-lived test of an unreleased upstream PR, pin to a full 40-character commit
93
+ SHA and leave `CPFLOW_VERSION` unset:
93
94
 
94
95
  ```sh
95
- gh workflow run cpflow-deploy-review-app.yml --ref <your-pr-branch> -f pr_number=<pr-number>
96
- gh workflow run cpflow-delete-review-app.yml --ref <your-pr-branch> -f pr_number=<pr-number>
97
- gh workflow run cpflow-help-command.yml --ref <your-pr-branch> -f pr_number=<pr-number>
96
+ bin/pin-cpflow-github-ref <40-character-control-plane-flow-commit-sha>
97
+ bin/test-cpflow-github-flow ruby /path/to/control-plane-flow/bin/cpflow
98
98
  ```
99
99
 
100
- `workflow_dispatch` runs use the workflow file from the `--ref` you pass, so this is the supported way to test PR-branch workflow edits before merge. After merge, comment triggers go back to running the default-branch workflow code as usual.
101
-
102
- </details>
100
+ ## Advanced Variables
101
+
102
+ Most apps do not need these:
103
+
104
+ | Name | Notes |
105
+ | --- | --- |
106
+ | `DOCKER_BUILD_EXTRA_ARGS` | Newline-delimited extra Docker build tokens. |
107
+ | `DOCKER_BUILD_SSH_KEY` | Private SSH key for Docker builds that fetch private dependencies. |
108
+ | `DOCKER_BUILD_SSH_KNOWN_HOSTS` | SSH known_hosts entries when SSH build hosts are not GitHub.com. |
109
+ | `REVIEW_APP_DEPLOYING_ICON_URL` | Cosmetic custom image URL for the animated deploying icon. Set to `none` to use the text fallback icon. |
110
+ | `STAGING_APP_BRANCH` | Custom staging branch. The branch must also appear in `cpflow-deploy-staging.yml`'s push filter. |
111
+ | `CPLN_CLI_VERSION` | Pin a specific `@controlplane/cli` version; normally leave unset. |
112
+
113
+ The PR-open help workflow posts a short command reference whenever the generated
114
+ wrapper exists. That is intentional for configured demo repos. Forks or clones
115
+ that copy the workflow before configuring Control Plane can remove
116
+ `.github/workflows/cpflow-review-app-help.yml` or uncomment and adapt the
117
+ wrapper-level `if:` guard shown in that file, for example
118
+ `vars.REVIEW_APP_PREFIX != '' || vars.CPLN_ORG_STAGING != ''`.
@@ -10,13 +10,8 @@ permissions:
10
10
 
11
11
  jobs:
12
12
  cleanup:
13
- # Keep the @ref in `uses:` and `control_plane_flow_ref` below in sync: the
14
- # first selects the reusable workflow, the second selects its shared actions.
13
+ # Cleanup targets the current inferred review-app prefix. If you changed
14
+ # naming conventions, manually delete review apps under the old prefix.
15
15
  uses: shakacode/control-plane-flow/.github/workflows/cpflow-cleanup-stale-review-apps.yml@__CPFLOW_GITHUB_ACTIONS_REF__
16
- with:
17
- control_plane_flow_ref: __CPFLOW_GITHUB_ACTIONS_REF__
18
- # `secrets: inherit` passes all caller repository secrets to the trusted
19
- # upstream workflow. The upstream workflow only reads the named secrets it
20
- # references, but GitHub does not enforce that boundary. Strict consumers can
21
- # set CPFLOW_GITHUB_ACTIONS_REF to an immutable commit SHA.
22
- secrets: inherit
16
+ secrets:
17
+ CPLN_TOKEN_STAGING: ${{ secrets.CPLN_TOKEN_STAGING }}
@@ -31,13 +31,6 @@ jobs:
31
31
  github.event_name == 'workflow_dispatch'
32
32
  # This `if:` mirrors the upstream job guard to avoid a billable workflow_call
33
33
  # when the event does not match. Keep both conditions in sync.
34
- # Keep the @ref in `uses:` and `control_plane_flow_ref` below in sync: the
35
- # first selects the reusable workflow, the second selects its shared actions.
36
34
  uses: shakacode/control-plane-flow/.github/workflows/cpflow-delete-review-app.yml@__CPFLOW_GITHUB_ACTIONS_REF__
37
- with:
38
- control_plane_flow_ref: __CPFLOW_GITHUB_ACTIONS_REF__
39
- # `secrets: inherit` passes all caller repository secrets to the trusted
40
- # upstream workflow. The upstream workflow only reads the named secrets it
41
- # references, but GitHub does not enforce that boundary. Strict consumers can
42
- # set CPFLOW_GITHUB_ACTIONS_REF to an immutable commit SHA.
43
- secrets: inherit
35
+ secrets:
36
+ CPLN_TOKEN_STAGING: ${{ secrets.CPLN_TOKEN_STAGING }}
@@ -30,13 +30,7 @@ jobs:
30
30
  github.event.issue.pull_request &&
31
31
  contains(fromJson('["+review-app-deploy","+review-app-deploy\n","+review-app-deploy\r\n"]'), github.event.comment.body) &&
32
32
  contains(fromJson('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association))
33
- # Keep the @ref in `uses:` and `control_plane_flow_ref` below in sync: the
34
- # first selects the reusable workflow, the second selects its shared actions.
35
33
  uses: shakacode/control-plane-flow/.github/workflows/cpflow-deploy-review-app.yml@__CPFLOW_GITHUB_ACTIONS_REF__
36
- with:
37
- control_plane_flow_ref: __CPFLOW_GITHUB_ACTIONS_REF__
38
- # `secrets: inherit` passes all caller repository secrets to the trusted
39
- # upstream workflow. The upstream workflow only reads the named secrets it
40
- # references, but GitHub does not enforce that boundary. Strict consumers can
41
- # set CPFLOW_GITHUB_ACTIONS_REF to an immutable commit SHA.
42
- secrets: inherit
34
+ secrets:
35
+ CPLN_TOKEN_STAGING: ${{ secrets.CPLN_TOKEN_STAGING }}
36
+ DOCKER_BUILD_SSH_KEY: ${{ secrets.DOCKER_BUILD_SSH_KEY }}
@@ -16,14 +16,9 @@ permissions:
16
16
 
17
17
  jobs:
18
18
  deploy-staging:
19
- # Keep the @ref in `uses:` and `control_plane_flow_ref` below in sync: the
20
- # first selects the reusable workflow, the second selects its shared actions.
21
19
  uses: shakacode/control-plane-flow/.github/workflows/cpflow-deploy-staging.yml@__CPFLOW_GITHUB_ACTIONS_REF__
22
20
  with:
23
- control_plane_flow_ref: __CPFLOW_GITHUB_ACTIONS_REF__
24
21
  staging_app_branch_default: "__STAGING_BRANCH_DEFAULT__"
25
- # `secrets: inherit` passes all caller repository secrets to the trusted
26
- # upstream workflow. The upstream workflow only reads the named secrets it
27
- # references, but GitHub does not enforce that boundary. Strict consumers can
28
- # set CPFLOW_GITHUB_ACTIONS_REF to an immutable commit SHA.
29
- secrets: inherit
22
+ secrets:
23
+ CPLN_TOKEN_STAGING: ${{ secrets.CPLN_TOKEN_STAGING }}
24
+ DOCKER_BUILD_SSH_KEY: ${{ secrets.DOCKER_BUILD_SSH_KEY }}
@@ -23,13 +23,4 @@ jobs:
23
23
  contains(fromJson('["+review-app-help","+review-app-help\n","+review-app-help\r\n"]'), github.event.comment.body) &&
24
24
  contains(fromJson('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) ||
25
25
  github.event_name == 'workflow_dispatch'
26
- # control_plane_flow_ref is accepted by the upstream workflow for wrapper
27
- # consistency; this helper checks out caller content only.
28
26
  uses: shakacode/control-plane-flow/.github/workflows/cpflow-help-command.yml@__CPFLOW_GITHUB_ACTIONS_REF__
29
- with:
30
- control_plane_flow_ref: __CPFLOW_GITHUB_ACTIONS_REF__
31
- # `secrets: inherit` passes all caller repository secrets to the trusted
32
- # upstream workflow. This helper does not read them, but GitHub does not
33
- # enforce that boundary. Strict consumers can set CPFLOW_GITHUB_ACTIONS_REF
34
- # to an immutable commit SHA.
35
- secrets: inherit
@@ -16,13 +16,15 @@ permissions:
16
16
  jobs:
17
17
  promote-to-production:
18
18
  if: github.event.inputs.confirm_promotion == 'promote'
19
- # Keep the @ref in `uses:` and `control_plane_flow_ref` below in sync: the
20
- # first selects the reusable workflow, the second selects its shared actions.
21
19
  uses: shakacode/control-plane-flow/.github/workflows/cpflow-promote-staging-to-production.yml@__CPFLOW_GITHUB_ACTIONS_REF__
22
20
  with:
23
- control_plane_flow_ref: __CPFLOW_GITHUB_ACTIONS_REF__
24
- # `secrets: inherit` passes all caller repository secrets to the trusted
25
- # upstream workflow. The upstream workflow only reads the named secrets it
26
- # references, but GitHub does not enforce that boundary. Strict consumers can
27
- # set CPFLOW_GITHUB_ACTIONS_REF to an immutable commit SHA.
28
- secrets: inherit
21
+ # Keep CPLN_TOKEN_PRODUCTION as a secret on this protected GitHub
22
+ # Environment. The caller passes the environment name, the upstream
23
+ # reusable workflow runs its production job in that environment, and
24
+ # GitHub exposes environment secrets only after required reviewers approve.
25
+ production_environment: production
26
+ # Only pass the staging token explicitly. CPLN_TOKEN_PRODUCTION must live on
27
+ # the protected production Environment, where GitHub exposes it only after
28
+ # the required reviewers approve this job.
29
+ secrets:
30
+ CPLN_TOKEN_STAGING: ${{ secrets.CPLN_TOKEN_STAGING }}
@@ -14,14 +14,8 @@ permissions:
14
14
 
15
15
  jobs:
16
16
  show-help:
17
- if: vars.REVIEW_APP_PREFIX != ''
18
- # control_plane_flow_ref is accepted by the upstream workflow for wrapper
19
- # consistency; this helper does not check out shared actions.
17
+ # This is intentionally unconditional: committing this wrapper opts the repo in
18
+ # to PR-open help. Remove it, or uncomment and adapt this guard, if forks or
19
+ # clones should stay quiet until Control Plane is configured:
20
+ # if: vars.REVIEW_APP_PREFIX != '' || vars.CPLN_ORG_STAGING != ''
20
21
  uses: shakacode/control-plane-flow/.github/workflows/cpflow-review-app-help.yml@__CPFLOW_GITHUB_ACTIONS_REF__
21
- with:
22
- control_plane_flow_ref: __CPFLOW_GITHUB_ACTIONS_REF__
23
- # `secrets: inherit` passes all caller repository secrets to the trusted
24
- # upstream workflow. This helper does not read them, but GitHub does not
25
- # enforce that boundary. Strict consumers can set CPFLOW_GITHUB_ACTIONS_REF
26
- # to an immutable commit SHA.
27
- secrets: inherit
@@ -8,6 +8,9 @@ USAGE = <<~USAGE
8
8
 
9
9
  Use a release tag for normal operation, e.g. v5.0.0.
10
10
  Use a full 40-character commit SHA for temporary unreleased upstream testing.
11
+ This only updates generated reusable-workflow `uses:` refs. The called
12
+ workflows load their own matching shared actions from that same workflow
13
+ commit automatically. Regenerate from the cpflow gem when templates changed.
11
14
  Use --allow-moving-ref only for short-lived local branch/ref experiments.
12
15
  USAGE
13
16
 
@@ -56,7 +59,6 @@ workflow_paths.each do |path|
56
59
  text = File.read(path)
57
60
  updated = text
58
61
  .gsub(%r{(uses:\s+shakacode/control-plane-flow/\.github/workflows/[^@\s]+@)[^\s]+}, "\\1#{ref}")
59
- .gsub(/(\bcontrol_plane_flow_ref:\s*)\S+/, "\\1#{ref}")
60
62
 
61
63
  next if updated == text
62
64
 
@@ -43,6 +43,7 @@ ruby <<'RUBY'
43
43
  require "yaml"
44
44
 
45
45
  CONTROL_PLANE_FLOW_WORKFLOW = %r{\Ashakacode/control-plane-flow/\.github/workflows/[^@\s]+@([^\s]+)\z}
46
+ PROMOTE_WORKFLOW = %r{\Ashakacode/control-plane-flow/\.github/workflows/cpflow-promote-staging-to-production\.yml@[^\s]+\z}
46
47
 
47
48
  refs = Hash.new { |hash, key| hash[key] = [] }
48
49
 
@@ -55,21 +56,32 @@ Dir[".github/workflows/cpflow-*.yml"].sort.each do |path|
55
56
  input_ref = with["control_plane_flow_ref"]
56
57
  uses_match = job["uses"].to_s.match(CONTROL_PLANE_FLOW_WORKFLOW)
57
58
 
58
- unless uses_match
59
- abort "#{path}:#{job_name} has control_plane_flow_ref but no control-plane-flow reusable workflow" if input_ref
59
+ if job["secrets"] == "inherit"
60
+ abort "#{path}:#{job_name} uses secrets: inherit; pass only the named secrets the upstream workflow needs"
61
+ end
62
+
63
+ if input_ref
64
+ abort "#{path}:#{job_name} passes obsolete control_plane_flow_ref. Remove it; the upstream reusable workflow checks out its own source from GitHub's job.workflow_* context."
65
+ end
60
66
 
67
+ unless uses_match
61
68
  next
62
69
  end
63
70
 
64
71
  uses_ref = uses_match[1]
65
72
  refs[uses_ref] << "#{path}:#{job_name}"
66
73
 
67
- if input_ref
68
- refs[input_ref] << "#{path}:#{job_name}"
69
- abort "#{path}:#{job_name} mismatched cpflow refs: #{uses_ref}, #{input_ref}" if uses_ref != input_ref
70
- elsif job.key?("secrets")
71
- abort "#{path}:#{job_name} inherits secrets but is missing control_plane_flow_ref for #{uses_ref}"
74
+ if job["uses"].to_s.match?(PROMOTE_WORKFLOW)
75
+ if with["production_environment"].to_s.strip.empty?
76
+ abort "#{path}:#{job_name} must set production_environment so GitHub can expose production environment secrets after approval"
77
+ end
78
+
79
+ secrets = job["secrets"].is_a?(Hash) ? job["secrets"] : {}
80
+ if secrets.key?("CPLN_TOKEN_PRODUCTION")
81
+ abort "#{path}:#{job_name} must not pass CPLN_TOKEN_PRODUCTION as a caller secret; store it on the protected production environment"
82
+ end
72
83
  end
84
+
73
85
  end
74
86
  end
75
87
 
@@ -86,4 +98,7 @@ end
86
98
  RUBY
87
99
 
88
100
  echo "==> actionlint"
89
- actionlint -ignore "SC2129" .github/workflows/cpflow-*.yml
101
+ actionlint \
102
+ -ignore "SC2129" \
103
+ -ignore 'property "workflow_(ref|sha|repository|file_path)" is not defined in object type' \
104
+ .github/workflows/cpflow-*.yml
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Gordon
@@ -82,6 +82,7 @@ files:
82
82
  - ".github/actions/cpflow-delete-control-plane-app/action.yml"
83
83
  - ".github/actions/cpflow-delete-control-plane-app/delete-app.sh"
84
84
  - ".github/actions/cpflow-detect-release-phase/action.yml"
85
+ - ".github/actions/cpflow-resolve-review-config/action.yml"
85
86
  - ".github/actions/cpflow-setup-environment/action.yml"
86
87
  - ".github/actions/cpflow-validate-config/action.yml"
87
88
  - ".github/actions/cpflow-wait-for-health/action.yml"