cpflow 6.0.0 → 6.1.0

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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/.agents/bin/README.md +3 -2
  3. data/.agents/bin/docs +2 -1
  4. data/.agents/bin/lint +2 -1
  5. data/.agents/shaka/bin/setup +6 -0
  6. data/.agents/shaka/bin/test +6 -0
  7. data/.agents/shaka/bin/validate +7 -0
  8. data/.agents/{agent-workflow.yml → shaka/config.yml} +1 -1
  9. data/.agents/shaka.md +3 -2
  10. data/.github/actions/cpflow-setup-environment/action.yml +1 -1
  11. data/.github/dependabot.yml +10 -5
  12. data/.github/scripts/deployment_lock.py +141 -0
  13. data/.github/workflows/claude-code-review.yml +1 -1
  14. data/.github/workflows/claude.yml +1 -1
  15. data/.github/workflows/command_docs.yml +1 -1
  16. data/.github/workflows/cpflow-cleanup-stale-review-apps.yml +4 -11
  17. data/.github/workflows/cpflow-delete-review-app.yml +6 -13
  18. data/.github/workflows/cpflow-deploy-review-app.yml +225 -108
  19. data/.github/workflows/cpflow-deploy-staging.yml +5 -11
  20. data/.github/workflows/cpflow-promote-staging-to-production.yml +7 -7
  21. data/.github/workflows/rspec-shared.yml +3 -3
  22. data/.github/workflows/rspec.yml +2 -2
  23. data/.github/workflows/rubocop.yml +1 -1
  24. data/.github/workflows/trigger-docs-site.yml +1 -1
  25. data/AGENTS.md +4 -4
  26. data/CHANGELOG.md +26 -1
  27. data/CONTRIBUTING.md +9 -5
  28. data/Gemfile.lock +15 -10
  29. data/README.md +1 -1
  30. data/cpflow.gemspec +1 -1
  31. data/docs/ai-github-flow-prompt.md +104 -8
  32. data/docs/ci-automation.md +174 -59
  33. data/docs/commands.md +11 -6
  34. data/lib/command/ai_github_flow_prompt.rb +10 -13
  35. data/lib/command/ai_github_flow_prompt.txt +103 -0
  36. data/lib/command/apply_template.rb +12 -1
  37. data/lib/command/base.rb +10 -0
  38. data/lib/command/generate_github_actions.rb +8 -16
  39. data/lib/command/run.rb +7 -7
  40. data/lib/command/setup_app.rb +6 -1
  41. data/lib/command/update_github_actions.rb +28 -2
  42. data/lib/core/bootstrap_image.rb +21 -0
  43. data/lib/core/controlplane.rb +7 -6
  44. data/lib/cpflow/version.rb +1 -1
  45. data/lib/github_flow_templates/.github/cpflow-help.md +2 -2
  46. data/lib/github_flow_templates/.github/workflows/cpflow-promote-staging-to-production.yml +7 -7
  47. data/lib/github_flow_templates/bin/test-cpflow-github-flow +26 -4
  48. data/script/check_shell_scripts +3 -3
  49. metadata +12 -9
  50. data/.agents/bin/setup +0 -5
  51. data/.agents/bin/test +0 -5
  52. data/.agents/bin/validate +0 -6
  53. /data/.agents/{trusted-github-actors.yml → shaka/trusted-github-actors.yml} +0 -0
@@ -5,6 +5,11 @@ run-name: "Deploy Review App - PR #${{ github.event.pull_request.number || githu
5
5
  on:
6
6
  workflow_call:
7
7
  inputs:
8
+ deployment_lock:
9
+ description: Coordinate review-app deploys with other CI providers using a Control Plane lock.
10
+ required: false
11
+ type: boolean
12
+ default: false
8
13
  docker_build_extra_args:
9
14
  description: Optional newline-delimited extra docker build tokens, appended to the repository variable.
10
15
  required: false
@@ -332,7 +337,7 @@ jobs:
332
337
  (github.event_name == 'issue_comment' &&
333
338
  github.event.issue.pull_request &&
334
339
  contains(fromJson('["+review-app-deploy","+review-app-deploy\n","+review-app-deploy\r\n"]'), github.event.comment.body)))
335
- runs-on: ubuntu-latest
340
+ runs-on: ubuntu-24.04
336
341
  timeout-minutes: 45
337
342
  outputs:
338
343
  image_built: ${{ steps.build-image.outcome == 'success' }}
@@ -617,13 +622,6 @@ jobs:
617
622
  }
618
623
  }
619
624
 
620
- # No explicit ref: checkout's default resolves to this event's recorded commit
621
- # (GITHUB_SHA), which is trusted base-repository code and is exempt from checkout v7's fork-PR guard.
622
- - name: Checkout generated cpflow actions
623
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
624
- with:
625
- persist-credentials: false
626
-
627
625
  - name: Checkout control-plane-flow actions
628
626
  uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
629
627
  with:
@@ -634,7 +632,7 @@ jobs:
634
632
 
635
633
  - name: Validate required secrets and variables
636
634
  id: config
637
- uses: ./.github/actions/cpflow-validate-config
635
+ uses: ./.cpflow/.github/actions/cpflow-validate-config
638
636
  env:
639
637
  CPLN_TOKEN_STAGING: ${{ secrets.CPLN_TOKEN_STAGING }}
640
638
  with:
@@ -748,16 +746,113 @@ jobs:
748
746
  - name: Resolve review app config
749
747
  if: steps.config.outputs.ready == 'true' && steps.source.outputs.allowed == 'true'
750
748
  id: review-config
751
- uses: ./.github/actions/cpflow-resolve-review-config
749
+ uses: ./.cpflow/.github/actions/cpflow-resolve-review-config
752
750
  with:
753
751
  working_directory: app
754
752
  configured_cpln_org_staging: ${{ vars.CPLN_ORG_STAGING }}
755
753
  configured_review_app_prefix: ${{ vars.REVIEW_APP_PREFIX }}
756
754
  pr_number: ${{ env.PR_NUMBER }}
757
755
 
756
+ - name: Find tracked review deployment
757
+ if: steps.config.outputs.ready == 'true' && steps.source.outputs.allowed == 'true' && steps.intent.outputs.event == 'pull_request'
758
+ id: tracked-deployment
759
+ uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
760
+ env:
761
+ CPLN_TOKEN: ${{ secrets.CPLN_TOKEN_STAGING }}
762
+ with:
763
+ script: |
764
+ // Query the live GVC before Ruby setup; GitHub records can outlive stale cleanup.
765
+ const token = process.env.CPLN_TOKEN;
766
+ const authorization = /^Bearer\s+/i.test(token) ? token : `Bearer ${token}`;
767
+ const org = encodeURIComponent(process.env.CPLN_ORG);
768
+ const app = encodeURIComponent(process.env.APP_NAME);
769
+ if (/[\r\n]/.test(token)) throw new Error("Invalid Control Plane token format.");
770
+ const LOOKUP_TIMEOUT_SECONDS = "10";
771
+ const LOOKUP_CONNECT_TIMEOUT_SECONDS = "5";
772
+ const LOOKUP_RETRIES = "2";
773
+ const LOOKUP_RETRY_WINDOW_SECONDS = "30";
774
+ const result = await exec.getExecOutput("curl", [
775
+ "--disable", "--silent", "--show-error", "--output", "/dev/null", "--write-out", "%{http_code}",
776
+ "--header", "@-", "--connect-timeout", LOOKUP_CONNECT_TIMEOUT_SECONDS,
777
+ "--max-time", LOOKUP_TIMEOUT_SECONDS, "--retry", LOOKUP_RETRIES,
778
+ "--retry-max-time", LOOKUP_RETRY_WINDOW_SECONDS, "--retry-all-errors",
779
+ `https://api.cpln.io/org/${org}/gvc/${app}`
780
+ ], {input: Buffer.from(`Authorization: ${authorization}\n`), silent: true, ignoreReturnCode: true});
781
+ if (result.exitCode !== 0) throw new Error("Review app lookup failed after bounded retries.");
782
+ const status = Number(result.stdout.trim());
783
+ if (status !== 200 && status !== 404) {
784
+ throw new Error(`Review app lookup failed (HTTP ${status}).`);
785
+ }
786
+ core.setOutput("tracked", status === 200 ? "true" : "false");
787
+
788
+ - name: Create initial PR comment
789
+ if: steps.config.outputs.ready == 'true' && steps.source.outputs.allowed == 'true' && steps.intent.outputs.event != 'pull_request'
790
+ id: create-comment
791
+ uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
792
+ with:
793
+ script: |
794
+ const body = [
795
+ "<!-- cpflow-review-app -->",
796
+ "## 🚀 Starting deployment process...",
797
+ "",
798
+ `_Preparing review app deployment for PR #${process.env.PR_NUMBER}, commit ${process.env.PR_SHA}_`
799
+ ].join("\n");
800
+
801
+ const result = await github.rest.issues.createComment({
802
+ owner: context.repo.owner,
803
+ repo: context.repo.repo,
804
+ issue_number: Number(process.env.PR_NUMBER),
805
+ body
806
+ });
807
+ core.setOutput("comment-id", result.data.id);
808
+
809
+ - name: Set deployment links
810
+ if: steps.config.outputs.ready == 'true' && steps.source.outputs.allowed == 'true'
811
+ uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
812
+ with:
813
+ script: |
814
+ const workflowUrl = `${process.env.GITHUB_SERVER_URL}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
815
+ core.exportVariable("WORKFLOW_URL", workflowUrl);
816
+ core.exportVariable(
817
+ "CONSOLE_URL",
818
+ `https://console.cpln.io/console/org/${process.env.CPLN_ORG}/gvc/${process.env.APP_NAME}/-info`
819
+ );
820
+
821
+ - name: Initialize GitHub deployment
822
+ if: steps.config.outputs.ready == 'true' && steps.source.outputs.allowed == 'true' && (steps.intent.outputs.event != 'pull_request' || steps.tracked-deployment.outputs.tracked == 'true')
823
+ id: init-deployment
824
+ uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
825
+ with:
826
+ script: |
827
+ const deployment = await github.rest.repos.createDeployment({
828
+ owner: context.repo.owner,
829
+ repo: context.repo.repo,
830
+ ref: process.env.PR_SHA,
831
+ environment: `review/${process.env.APP_NAME}`,
832
+ transient_environment: true,
833
+ production_environment: false,
834
+ auto_merge: false,
835
+ required_contexts: [], // intentional: review apps deploy regardless of required status checks
836
+ payload: {pr_number: Number(process.env.PR_NUMBER), run_id: context.runId},
837
+ description: `Control Plane review app for PR #${process.env.PR_NUMBER}`
838
+ });
839
+
840
+ core.setOutput("deployment-id", deployment.data.id);
841
+
842
+ await github.rest.repos.createDeploymentStatus({
843
+ owner: context.repo.owner,
844
+ repo: context.repo.repo,
845
+ deployment_id: deployment.data.id,
846
+ state: "in_progress",
847
+ description: "Deployment started",
848
+ log_url: process.env.WORKFLOW_URL
849
+ });
850
+
851
+ return deployment.data.id;
852
+
758
853
  - name: Setup environment
759
854
  if: steps.config.outputs.ready == 'true' && steps.source.outputs.allowed == 'true'
760
- uses: ./.github/actions/cpflow-setup-environment
855
+ uses: ./.cpflow/.github/actions/cpflow-setup-environment
761
856
  with:
762
857
  token: ${{ secrets.CPLN_TOKEN_STAGING }}
763
858
  org: ${{ steps.review-config.outputs.cpln_org }}
@@ -769,11 +864,24 @@ jobs:
769
864
  - name: Detect release phase support
770
865
  if: steps.config.outputs.ready == 'true' && steps.source.outputs.allowed == 'true'
771
866
  id: release-phase
772
- uses: ./.github/actions/cpflow-detect-release-phase
867
+ uses: ./.cpflow/.github/actions/cpflow-detect-release-phase
773
868
  with:
774
869
  app_name: ${{ steps.review-config.outputs.app_name }}
775
870
  working_directory: app
776
871
 
872
+ - name: Acquire shared deployment lock
873
+ id: deploy-lock
874
+ if: inputs.deployment_lock && steps.config.outputs.ready == 'true' && steps.source.outputs.allowed == 'true'
875
+ shell: bash
876
+ env:
877
+ CPLN_TOKEN: ${{ secrets.CPLN_TOKEN_STAGING }}
878
+ DEPLOY_OWNER: github:${{ github.repository }}:${{ github.run_id }}:${{ github.run_attempt }}
879
+ run: |
880
+ set -euo pipefail
881
+ python3 .cpflow/.github/scripts/deployment_lock.py acquire \
882
+ --org "$CPLN_ORG" --app "$APP_NAME" --owner "$DEPLOY_OWNER" \
883
+ --receipt "$RUNNER_TEMP/cpflow-deploy-lock.json"
884
+
777
885
  - name: Check if review app exists
778
886
  if: steps.config.outputs.ready == 'true' && steps.source.outputs.allowed == 'true'
779
887
  id: check-app
@@ -824,85 +932,9 @@ jobs:
824
932
  echo "Create it with +review-app-deploy as the PR comment body."
825
933
  } >> "$GITHUB_STEP_SUMMARY"
826
934
 
827
- - name: Setup review app if it does not exist yet
828
- id: setup-review-app
829
- if: steps.config.outputs.ready == 'true' && steps.source.outputs.allowed == 'true' && steps.check-app.outputs.exists != 'true' && steps.intent.outputs.event != 'pull_request'
830
- working-directory: app
831
- shell: bash
832
- run: |
833
- set -euo pipefail
834
- cpflow setup-app -a "${APP_NAME}" --org "${CPLN_ORG}"
835
-
836
- - name: Refresh existing review app templates
837
- if: steps.config.outputs.ready == 'true' && steps.source.outputs.allowed == 'true' && steps.check-app.outputs.exists == 'true'
838
- working-directory: app
839
- shell: bash
840
- run: |
841
- set -euo pipefail
842
- cpflow setup-app -a "${APP_NAME}" --org "${CPLN_ORG}" --refresh-templates
843
-
844
- - name: Create initial PR comment
845
- if: steps.config.outputs.ready == 'true' && steps.source.outputs.allowed == 'true' && (steps.check-app.outputs.exists == 'true' || steps.setup-review-app.outcome == 'success')
846
- id: create-comment
847
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
848
- with:
849
- script: |
850
- const body = [
851
- "## 🚀 Starting deployment process...",
852
- "",
853
- `_Preparing review app deployment for PR #${process.env.PR_NUMBER}, commit ${process.env.PR_SHA}_`
854
- ].join("\n");
855
-
856
- const result = await github.rest.issues.createComment({
857
- owner: context.repo.owner,
858
- repo: context.repo.repo,
859
- issue_number: Number(process.env.PR_NUMBER),
860
- body
861
- });
862
- core.setOutput("comment-id", result.data.id);
863
-
864
- - name: Set deployment links
865
- if: steps.config.outputs.ready == 'true' && steps.source.outputs.allowed == 'true' && (steps.check-app.outputs.exists == 'true' || steps.setup-review-app.outcome == 'success')
866
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
867
- with:
868
- script: |
869
- const workflowUrl = `${process.env.GITHUB_SERVER_URL}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
870
- core.exportVariable("WORKFLOW_URL", workflowUrl);
871
- core.exportVariable(
872
- "CONSOLE_URL",
873
- `https://console.cpln.io/console/org/${process.env.CPLN_ORG}/gvc/${process.env.APP_NAME}/-info`
874
- );
875
-
876
- - name: Initialize GitHub deployment
877
- if: steps.config.outputs.ready == 'true' && steps.source.outputs.allowed == 'true' && (steps.check-app.outputs.exists == 'true' || steps.setup-review-app.outcome == 'success')
878
- id: init-deployment
879
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
880
- with:
881
- script: |
882
- const deployment = await github.rest.repos.createDeployment({
883
- owner: context.repo.owner,
884
- repo: context.repo.repo,
885
- ref: process.env.PR_SHA,
886
- environment: `review/${process.env.APP_NAME}`,
887
- transient_environment: true,
888
- production_environment: false,
889
- auto_merge: false,
890
- required_contexts: [], // intentional: review apps deploy regardless of required status checks
891
- description: `Control Plane review app for PR #${process.env.PR_NUMBER}`
892
- });
893
-
894
- await github.rest.repos.createDeploymentStatus({
895
- owner: context.repo.owner,
896
- repo: context.repo.repo,
897
- deployment_id: deployment.data.id,
898
- state: "in_progress",
899
- description: "Deployment started"
900
- });
901
-
902
- return deployment.data.id;
903
935
 
904
936
  - name: Update PR comment with build status
905
- if: steps.config.outputs.ready == 'true' && steps.source.outputs.allowed == 'true' && (steps.check-app.outputs.exists == 'true' || steps.setup-review-app.outcome == 'success')
937
+ if: steps.config.outputs.ready == 'true' && steps.source.outputs.allowed == 'true' && (steps.check-app.outputs.exists == 'true' || steps.intent.outputs.event != 'pull_request')
906
938
  uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
907
939
  env:
908
940
  COMMENT_ID: ${{ steps.create-comment.outputs.comment-id }}
@@ -930,8 +962,8 @@ jobs:
930
962
 
931
963
  - name: Build Docker image
932
964
  id: build-image
933
- if: steps.config.outputs.ready == 'true' && steps.source.outputs.allowed == 'true' && (steps.check-app.outputs.exists == 'true' || steps.setup-review-app.outcome == 'success')
934
- uses: ./.github/actions/cpflow-build-docker-image
965
+ if: steps.config.outputs.ready == 'true' && steps.source.outputs.allowed == 'true' && (steps.check-app.outputs.exists == 'true' || steps.intent.outputs.event != 'pull_request')
966
+ uses: ./.cpflow/.github/actions/cpflow-build-docker-image
935
967
  with:
936
968
  app_name: ${{ steps.review-config.outputs.app_name }}
937
969
  org: ${{ steps.review-config.outputs.cpln_org }}
@@ -945,6 +977,39 @@ jobs:
945
977
  docker_build_ssh_known_hosts: ${{ vars.DOCKER_BUILD_SSH_KNOWN_HOSTS }}
946
978
  working_directory: app
947
979
 
980
+ - name: Verify built PR image
981
+ id: built-image
982
+ if: steps.build-image.outcome == 'success'
983
+ working-directory: app
984
+ shell: bash
985
+ run: |
986
+ set -euo pipefail
987
+ image="$(cpflow latest-image -a "${APP_NAME}" --org "${CPLN_ORG}")"
988
+ if [[ ! "${PR_SHA}" =~ ^[a-f0-9]{40}$ || ! "${image}" =~ ^"${APP_NAME}":[0-9]+_"${PR_SHA}"$ ]]; then
989
+ echo "::error::Registry image does not match this app and the full PR head." >&2
990
+ exit 1
991
+ fi
992
+ echo "image=${image}" >> "$GITHUB_OUTPUT"
993
+
994
+ - name: Setup review app if it does not exist yet
995
+ id: setup-review-app
996
+ if: steps.config.outputs.ready == 'true' && steps.source.outputs.allowed == 'true' && steps.check-app.outputs.exists != 'true' && steps.intent.outputs.event != 'pull_request'
997
+ working-directory: app
998
+ shell: bash
999
+ run: |
1000
+ set -euo pipefail
1001
+ cpflow setup-app -a "${APP_NAME}" --org "${CPLN_ORG}"
1002
+
1003
+ - name: Refresh existing review app templates
1004
+ env:
1005
+ BUILT_IMAGE: ${{ steps.built-image.outputs.image }}
1006
+ if: steps.config.outputs.ready == 'true' && steps.source.outputs.allowed == 'true' && steps.check-app.outputs.exists == 'true'
1007
+ working-directory: app
1008
+ shell: bash
1009
+ run: |
1010
+ set -euo pipefail
1011
+ cpflow setup-app -a "${APP_NAME}" --org "${CPLN_ORG}" --refresh-templates --bootstrap-image "${BUILT_IMAGE}"
1012
+
948
1013
  - name: Update PR comment with deploy status
949
1014
  if: steps.config.outputs.ready == 'true' && steps.source.outputs.allowed == 'true' && (steps.check-app.outputs.exists == 'true' || steps.setup-review-app.outcome == 'success')
950
1015
  uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
@@ -1019,7 +1084,7 @@ jobs:
1019
1084
  - name: Wait for deployment health
1020
1085
  if: steps.config.outputs.ready == 'true' && steps.source.outputs.allowed == 'true' && (steps.check-app.outputs.exists == 'true' || steps.setup-review-app.outcome == 'success')
1021
1086
  id: health-check
1022
- uses: ./.github/actions/cpflow-wait-for-health
1087
+ uses: ./.cpflow/.github/actions/cpflow-wait-for-health
1023
1088
  with:
1024
1089
  workload_name: ${{ env.PRIMARY_WORKLOAD || 'rails' }}
1025
1090
  app_name: ${{ steps.review-config.outputs.app_name }}
@@ -1107,33 +1172,68 @@ jobs:
1107
1172
  } >> "$GITHUB_OUTPUT"
1108
1173
 
1109
1174
  - name: Finalize deployment status
1110
- if: always() && steps.config.outputs.ready == 'true' && steps.source.outputs.allowed == 'true' && (steps.check-app.outputs.exists == 'true' || steps.setup-review-app.outcome == 'success')
1175
+ if: always() && steps.source.outputs.allowed == 'true'
1111
1176
  uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
1112
1177
  env:
1113
1178
  COMMENT_ID: ${{ steps.create-comment.outputs.comment-id }}
1114
- DEPLOYMENT_ID: ${{ steps.init-deployment.outputs.result }}
1179
+ DEPLOYMENT_ID: ${{ steps.init-deployment.outputs.deployment-id }}
1115
1180
  APP_URL: ${{ steps.workload.outputs.app_url }}
1116
1181
  JOB_STATUS: ${{ job.status }}
1182
+ CHECK_APP_EXISTS: ${{ steps.check-app.outputs.exists }}
1183
+ INTENT_EVENT: ${{ steps.intent.outputs.event }}
1184
+ REVIEW_APP_TRACKED: ${{ steps.tracked-deployment.outputs.tracked }}
1117
1185
  with:
1118
1186
  script: |
1119
1187
  const commentId = Number(process.env.COMMENT_ID);
1120
- const deploymentId = process.env.DEPLOYMENT_ID;
1188
+ let deploymentId = process.env.DEPLOYMENT_ID;
1121
1189
  const appUrl = process.env.APP_URL;
1122
- const success = process.env.JOB_STATUS === "success";
1190
+ const workflowUrl = process.env.WORKFLOW_URL ||
1191
+ `${process.env.GITHUB_SERVER_URL}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
1192
+ const cancelled = process.env.JOB_STATUS === "cancelled";
1193
+ const skipped = process.env.JOB_STATUS === "success" &&
1194
+ process.env.INTENT_EVENT === "pull_request" && process.env.CHECK_APP_EXISTS !== "true";
1195
+ const success = process.env.JOB_STATUS === "success" && !skipped && Boolean(appUrl);
1196
+ const state = skipped ? "inactive" : success ? "success" : "failure";
1197
+ const outcome = skipped ? "Review app not created" : cancelled ? "Review App Deployment Cancelled" :
1198
+ success ? "Review app ready" : "Review App Deployment Failed";
1199
+
1200
+ if (skipped && !deploymentId) return;
1201
+ // A failed early lookup cannot establish whether an automatic app exists.
1202
+ if (process.env.INTENT_EVENT === "pull_request" &&
1203
+ process.env.CHECK_APP_EXISTS !== "true" && process.env.REVIEW_APP_TRACKED !== "true") return;
1204
+
1205
+ // Record attempts that began without a deployment, such as an app found only after setup.
1206
+ if (!deploymentId && process.env.APP_NAME) {
1207
+ const deployment = await github.rest.repos.createDeployment({
1208
+ owner: context.repo.owner,
1209
+ repo: context.repo.repo,
1210
+ ref: process.env.PR_SHA,
1211
+ environment: `review/${process.env.APP_NAME}`,
1212
+ transient_environment: true,
1213
+ production_environment: false,
1214
+ auto_merge: false,
1215
+ required_contexts: [],
1216
+ payload: {pr_number: Number(process.env.PR_NUMBER), run_id: context.runId},
1217
+ description: `Control Plane review app for PR #${process.env.PR_NUMBER}`
1218
+ });
1219
+ deploymentId = deployment.data.id;
1220
+ }
1123
1221
 
1124
1222
  if (deploymentId) {
1125
1223
  await github.rest.repos.createDeploymentStatus({
1126
1224
  owner: context.repo.owner,
1127
1225
  repo: context.repo.repo,
1128
1226
  deployment_id: Number(deploymentId),
1129
- state: success ? "success" : "failure",
1227
+ state,
1130
1228
  environment: `review/${process.env.APP_NAME}`,
1131
1229
  environment_url: success && appUrl ? appUrl : undefined,
1132
- log_url: process.env.WORKFLOW_URL,
1133
- description: success ? "Review app ready" : "Review app deployment failed"
1230
+ log_url: workflowUrl,
1231
+ description: outcome
1134
1232
  });
1135
1233
  }
1136
1234
 
1235
+ if (skipped) return;
1236
+
1137
1237
  const successBody = [
1138
1238
  "## 🎉 Deploy Complete!",
1139
1239
  "",
@@ -1141,21 +1241,26 @@ jobs:
1141
1241
  "",
1142
1242
  `_Deployment successful for PR #${process.env.PR_NUMBER}, commit ${process.env.PR_SHA}_`,
1143
1243
  "",
1144
- `🎮 [Control Plane Console](${process.env.CONSOLE_URL})`,
1145
- `📋 [View Completed Action Build and Deploy Logs](${process.env.WORKFLOW_URL})`
1146
- ].join("\n");
1244
+ process.env.CONSOLE_URL ? `🎮 [Control Plane Console](${process.env.CONSOLE_URL})` : null,
1245
+ `📋 [View Completed Action Build and Deploy Logs](${workflowUrl})`
1246
+ ].filter(line => line !== null).join("\n");
1147
1247
 
1148
1248
  const failureBody = [
1149
- "## ❌ Review App Deployment Failed",
1249
+ `## ${outcome}`,
1150
1250
  "",
1151
- `_Deployment failed for PR #${process.env.PR_NUMBER}, commit ${process.env.PR_SHA}_`,
1251
+ `_PR #${process.env.PR_NUMBER}, commit ${process.env.PR_SHA}_`,
1152
1252
  "",
1153
- `🎮 [Control Plane Console](${process.env.CONSOLE_URL})`,
1154
- `📋 [View Failed Action Build and Deploy Logs](${process.env.WORKFLOW_URL})`
1155
- ].join("\n");
1253
+ process.env.CONSOLE_URL ? `🎮 [Control Plane Console](${process.env.CONSOLE_URL})` : null,
1254
+ `📋 [View Failed Action Build and Deploy Logs](${workflowUrl})`
1255
+ ].filter(line => line !== null).join("\n");
1156
1256
 
1157
1257
  if (!Number.isFinite(commentId) || commentId <= 0) {
1158
- core.warning("Skipping PR comment update because no comment id was created.");
1258
+ await github.rest.issues.createComment({
1259
+ owner: context.repo.owner,
1260
+ repo: context.repo.repo,
1261
+ issue_number: Number(process.env.PR_NUMBER),
1262
+ body: success ? successBody : failureBody
1263
+ });
1159
1264
  return;
1160
1265
  }
1161
1266
 
@@ -1165,3 +1270,15 @@ jobs:
1165
1270
  comment_id: commentId,
1166
1271
  body: success ? successBody : failureBody
1167
1272
  });
1273
+
1274
+ - name: Release shared deployment lock
1275
+ if: success() && steps.deploy-lock.outcome == 'success'
1276
+ shell: bash
1277
+ env:
1278
+ CPLN_TOKEN: ${{ secrets.CPLN_TOKEN_STAGING }}
1279
+ DEPLOY_OWNER: github:${{ github.repository }}:${{ github.run_id }}:${{ github.run_attempt }}
1280
+ run: |
1281
+ set -euo pipefail
1282
+ python3 .cpflow/.github/scripts/deployment_lock.py release \
1283
+ --org "$CPLN_ORG" --app "$APP_NAME" --owner "$DEPLOY_OWNER" \
1284
+ --receipt "$RUNNER_TEMP/cpflow-deploy-lock.json"
@@ -68,12 +68,6 @@ jobs:
68
68
  echo "is_deployable=false" >> "$GITHUB_OUTPUT"
69
69
  fi
70
70
 
71
- - name: Checkout generated cpflow actions
72
- if: steps.check-branch.outputs.is_deployable == 'true'
73
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
74
- with:
75
- persist-credentials: false
76
-
77
71
  - name: Checkout control-plane-flow actions
78
72
  if: steps.check-branch.outputs.is_deployable == 'true'
79
73
  uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -85,7 +79,7 @@ jobs:
85
79
 
86
80
  - name: Validate required secrets and variables
87
81
  if: steps.check-branch.outputs.is_deployable == 'true'
88
- uses: ./.github/actions/cpflow-validate-config
82
+ uses: ./.cpflow/.github/actions/cpflow-validate-config
89
83
  env:
90
84
  CPLN_TOKEN_STAGING: ${{ secrets.CPLN_TOKEN_STAGING }}
91
85
  CPLN_ORG_STAGING: ${{ vars.CPLN_ORG_STAGING }}
@@ -116,7 +110,7 @@ jobs:
116
110
  persist-credentials: false
117
111
 
118
112
  - name: Setup environment
119
- uses: ./.github/actions/cpflow-setup-environment
113
+ uses: ./.cpflow/.github/actions/cpflow-setup-environment
120
114
  with:
121
115
  token: ${{ secrets.CPLN_TOKEN_STAGING }}
122
116
  org: ${{ vars.CPLN_ORG_STAGING }}
@@ -126,7 +120,7 @@ jobs:
126
120
  control_plane_flow_ref: ${{ job.workflow_ref }}
127
121
 
128
122
  - name: Build Docker image
129
- uses: ./.github/actions/cpflow-build-docker-image
123
+ uses: ./.cpflow/.github/actions/cpflow-build-docker-image
130
124
  with:
131
125
  app_name: ${{ env.APP_NAME }}
132
126
  org: ${{ vars.CPLN_ORG_STAGING }}
@@ -158,7 +152,7 @@ jobs:
158
152
  persist-credentials: false
159
153
 
160
154
  - name: Setup environment
161
- uses: ./.github/actions/cpflow-setup-environment
155
+ uses: ./.cpflow/.github/actions/cpflow-setup-environment
162
156
  with:
163
157
  token: ${{ secrets.CPLN_TOKEN_STAGING }}
164
158
  org: ${{ vars.CPLN_ORG_STAGING }}
@@ -169,7 +163,7 @@ jobs:
169
163
 
170
164
  - name: Detect release phase support
171
165
  id: release-phase
172
- uses: ./.github/actions/cpflow-detect-release-phase
166
+ uses: ./.cpflow/.github/actions/cpflow-detect-release-phase
173
167
  with:
174
168
  app_name: ${{ env.APP_NAME }}
175
169
 
@@ -93,7 +93,7 @@ jobs:
93
93
  echo "org=$org" >> "$GITHUB_OUTPUT"
94
94
 
95
95
  - name: Setup staging environment
96
- uses: ./.github/actions/cpflow-setup-environment
96
+ uses: ./.cpflow/.github/actions/cpflow-setup-environment
97
97
  with:
98
98
  token: ${{ secrets.CPLN_TOKEN_STAGING }}
99
99
  org: ${{ steps.staging-org.outputs.org }}
@@ -104,7 +104,7 @@ jobs:
104
104
 
105
105
  - name: Preview commits before production approval
106
106
  id: preview
107
- uses: ./.github/actions/cpflow-preview-promotion
107
+ uses: ./.cpflow/.github/actions/cpflow-preview-promotion
108
108
  env:
109
109
  GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
110
110
  GH_REPO: ${{ github.repository }}
@@ -157,7 +157,7 @@ jobs:
157
157
  fi
158
158
 
159
159
  - name: Validate required secrets and variables
160
- uses: ./.github/actions/cpflow-validate-config
160
+ uses: ./.cpflow/.github/actions/cpflow-validate-config
161
161
  # Pass secrets via env so the composite action checks indirect shell
162
162
  # variables instead of interpolating secret values into a run script.
163
163
  env:
@@ -224,7 +224,7 @@ jobs:
224
224
  } >> "$GITHUB_OUTPUT"
225
225
 
226
226
  - name: Setup production environment
227
- uses: ./.github/actions/cpflow-setup-environment
227
+ uses: ./.cpflow/.github/actions/cpflow-setup-environment
228
228
  with:
229
229
  token: ${{ secrets.CPLN_TOKEN_PRODUCTION }}
230
230
  org: ${{ steps.cpln-orgs.outputs.production }}
@@ -286,7 +286,7 @@ jobs:
286
286
 
287
287
  - name: Detect release phase support
288
288
  id: release-phase
289
- uses: ./.github/actions/cpflow-detect-release-phase
289
+ uses: ./.cpflow/.github/actions/cpflow-detect-release-phase
290
290
  with:
291
291
  app_name: ${{ vars.PRODUCTION_APP_NAME }}
292
292
 
@@ -515,7 +515,7 @@ jobs:
515
515
  fi
516
516
 
517
517
  - name: Set up Docker Buildx
518
- uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0
518
+ uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
519
519
 
520
520
  - name: Copy image from staging
521
521
  id: copy-image
@@ -679,7 +679,7 @@ jobs:
679
679
 
680
680
  - name: Wait for deployment health
681
681
  id: health-check
682
- uses: ./.github/actions/cpflow-wait-for-health
682
+ uses: ./.cpflow/.github/actions/cpflow-wait-for-health
683
683
  with:
684
684
  workload_name: ${{ steps.workloads.outputs.primary }}
685
685
  app_name: ${{ vars.PRODUCTION_APP_NAME }}
@@ -35,7 +35,7 @@ jobs:
35
35
  with:
36
36
  persist-credentials: false
37
37
  - name: Set up Ruby
38
- uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
38
+ uses: ruby/setup-ruby@de492cf36cbab201753d720ce4f4e336cd688c94 # v1.336.0
39
39
  with:
40
40
  ruby-version: ${{ inputs.ruby_version }}
41
41
  bundler-cache: true
@@ -71,13 +71,13 @@ jobs:
71
71
 
72
72
  bundle exec rspec "${rspec_args[@]}"
73
73
  - name: Upload spec log
74
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
74
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
75
75
  if: always()
76
76
  with:
77
77
  name: spec-${{ inputs.test_tag }}-${{ github.run_id }}-${{ inputs.os_version }}-${{ inputs.ruby_version }}.log
78
78
  path: spec.log
79
79
  - name: Upload coverage results
80
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
80
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
81
81
  if: always()
82
82
  with:
83
83
  name: coverage-report-${{ inputs.test_tag }}-${{ github.run_id }}-${{ inputs.os_version }}-${{ inputs.ruby_version }}
@@ -58,7 +58,7 @@ jobs:
58
58
  with:
59
59
  persist-credentials: false
60
60
  - name: Set up Ruby
61
- uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
61
+ uses: ruby/setup-ruby@de492cf36cbab201753d720ce4f4e336cd688c94 # v1.336.0
62
62
  with:
63
63
  ruby-version: ${{ matrix.ruby-version }}
64
64
  bundler-cache: true
@@ -103,7 +103,7 @@ jobs:
103
103
  with:
104
104
  persist-credentials: false
105
105
  - name: Set up Ruby
106
- uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
106
+ uses: ruby/setup-ruby@de492cf36cbab201753d720ce4f4e336cd688c94 # v1.336.0
107
107
  with:
108
108
  ruby-version: "3.4"
109
109
  bundler-cache: true
@@ -31,7 +31,7 @@ jobs:
31
31
  - name: Analyze shell scripts
32
32
  run: script/check_shell_scripts
33
33
  - name: Set up Ruby
34
- uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
34
+ uses: ruby/setup-ruby@de492cf36cbab201753d720ce4f4e336cd688c94 # v1.336.0
35
35
  with:
36
36
  ruby-version: "3.2"
37
37
  bundler-cache: true
@@ -36,7 +36,7 @@ jobs:
36
36
  timeout-minutes: 5
37
37
  steps:
38
38
  - name: Generate GitHub App token
39
- uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
39
+ uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
40
40
  id: app-token
41
41
  with:
42
42
  app-id: ${{ secrets.DOCS_DISPATCH_APP_ID }}