-
Notifications
You must be signed in to change notification settings - Fork 373
[codex] Update cpflow review app guidance #764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
eb3d861
50e04fe
0e5f9e9
8b4be0c
7a11703
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| name: Build Docker Image | ||
| description: Builds and pushes the app image for a Control Plane workload | ||
|
|
||
| inputs: | ||
| app_name: | ||
| description: Name of the application | ||
| required: true | ||
| org: | ||
| description: Control Plane organization name | ||
| required: true | ||
| commit: | ||
| description: Commit SHA to tag the image with | ||
| required: true | ||
| pr_number: | ||
| description: Pull request number for status messaging | ||
| required: false | ||
| docker_build_extra_args: | ||
| description: Optional newline-delimited extra docker build tokens. Use key=value forms like --build-arg=FOO=bar. | ||
| required: false | ||
| docker_build_ssh_key: | ||
| description: Optional private SSH key used for Docker builds that fetch private dependencies with RUN --mount=type=ssh | ||
| required: false | ||
| docker_build_ssh_known_hosts: | ||
| description: Optional SSH known_hosts entries used with docker_build_ssh_key. Defaults to pinned GitHub.com host keys. | ||
| required: false | ||
|
|
||
| outputs: | ||
| image_tag: | ||
| description: Fully qualified image tag | ||
| value: ${{ steps.build.outputs.image_tag }} | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Build Docker image | ||
| id: build | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| PR_INFO="" | ||
| docker_build_args=() | ||
|
|
||
| if [[ -n "${{ inputs.pr_number }}" ]]; then | ||
| PR_INFO=" for PR #${{ inputs.pr_number }}" | ||
| fi | ||
|
|
||
| if [[ -n "${{ inputs.docker_build_extra_args }}" ]]; then | ||
| while IFS= read -r arg; do | ||
| arg="${arg%$'\r'}" | ||
| [[ -n "${arg}" ]] || continue | ||
|
|
||
| if [[ "${arg}" =~ [[:space:]] ]]; then | ||
| echo "docker_build_extra_args entries must be single docker-build tokens. " \ | ||
| "Use key=value forms like --build-arg=FOO=bar." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| docker_build_args+=("${arg}") | ||
| done <<< "${{ inputs.docker_build_extra_args }}" | ||
|
Comment on lines
+48
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shell injection risk: template expressions in inline script
The GitHub hardening guide recommends routing such values through env:
DOCKER_BUILD_EXTRA_ARGS: ${{ inputs.docker_build_extra_args }}
run: |
...
if [[ -n "$DOCKER_BUILD_EXTRA_ARGS" ]]; then
while IFS= read -r arg; do
...
done <<< "$DOCKER_BUILD_EXTRA_ARGS"
fiSince this action is only called from controlled workflows today the practical risk is low, but this pattern prevents future misuse if the action is ever invoked with PR-derived inputs. |
||
| fi | ||
|
|
||
| if [[ -n "${{ inputs.docker_build_ssh_key }}" ]]; then | ||
| mkdir -p ~/.ssh | ||
| chmod 700 ~/.ssh | ||
|
|
||
| if [[ -n "${{ inputs.docker_build_ssh_known_hosts }}" ]]; then | ||
| cat <<'EOF' > ~/.ssh/known_hosts | ||
| ${{ inputs.docker_build_ssh_known_hosts }} | ||
| EOF | ||
| else | ||
| cat <<'EOF' > ~/.ssh/known_hosts | ||
| github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl | ||
| github.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg= | ||
| github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk= | ||
| EOF | ||
| fi | ||
|
|
||
| chmod 600 ~/.ssh/known_hosts | ||
|
|
||
| eval "$(ssh-agent -s)" | ||
| trap 'ssh-agent -k >/dev/null' EXIT | ||
| ssh-add - <<< "${{ inputs.docker_build_ssh_key }}" | ||
| docker_build_args+=("--ssh=default") | ||
| fi | ||
|
|
||
| echo "🏗️ Building Docker image${PR_INFO} (commit ${{ inputs.commit }})..." | ||
| cpflow build-image -a "${{ inputs.app_name }}" --commit="${{ inputs.commit }}" --org="${{ inputs.org }}" "${docker_build_args[@]}" | ||
|
|
||
| image_tag="${{ inputs.org }}/${{ inputs.app_name }}:${{ inputs.commit }}" | ||
| echo "image_tag=${image_tag}" >> "$GITHUB_OUTPUT" | ||
| echo "✅ Docker image build successful${PR_INFO} (commit ${{ inputs.commit }})" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| name: Delete Control Plane App | ||
| description: Deletes a Control Plane app and all associated resources | ||
|
|
||
| inputs: | ||
| app_name: | ||
| description: Name of the application to delete | ||
| required: true | ||
| cpln_org: | ||
| description: Control Plane organization name | ||
| required: true | ||
| review_app_prefix: | ||
| description: Prefix used for review app names | ||
| required: true | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Delete application | ||
| shell: bash | ||
| run: ${{ github.action_path }}/delete-app.sh | ||
| env: | ||
| APP_NAME: ${{ inputs.app_name }} | ||
| CPLN_ORG: ${{ inputs.cpln_org }} | ||
| REVIEW_APP_PREFIX: ${{ inputs.review_app_prefix }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| : "${APP_NAME:?APP_NAME environment variable is required}" | ||
| : "${CPLN_ORG:?CPLN_ORG environment variable is required}" | ||
| : "${REVIEW_APP_PREFIX:?REVIEW_APP_PREFIX environment variable is required}" | ||
|
|
||
| expected_prefix="${REVIEW_APP_PREFIX}-" | ||
| if [[ "$APP_NAME" != "${expected_prefix}"* ]]; then | ||
| echo "❌ ERROR: refusing to delete an app outside the review app prefix" >&2 | ||
| echo "App name: $APP_NAME" >&2 | ||
| echo "Expected prefix: ${expected_prefix}" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "🔍 Checking if application exists: $APP_NAME" | ||
| exists_output="" | ||
| if ! exists_output="$(cpflow exists -a "$APP_NAME" --org "$CPLN_ORG" 2>&1)"; then | ||
| case "$exists_output" in | ||
| *"Double check your org"*|*"Unknown API token format"*|*"ERROR"*|*"Error:"*|*"Traceback"*|*"Net::"*) | ||
| echo "❌ ERROR: failed to determine whether application exists: $APP_NAME" >&2 | ||
| printf '%s\n' "$exists_output" >&2 | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
|
||
| if [[ -n "$exists_output" ]]; then | ||
| printf '%s\n' "$exists_output" | ||
| fi | ||
|
|
||
| echo "⚠️ Application does not exist: $APP_NAME" | ||
| exit 0 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exists errors skip deletionMedium Severity When Reviewed by Cursor Bugbot for commit 7a11703. Configure here. |
||
| fi | ||
|
|
||
| if [[ -n "$exists_output" ]]; then | ||
| printf '%s\n' "$exists_output" | ||
| fi | ||
|
|
||
| echo "🗑️ Deleting application: $APP_NAME" | ||
| cpflow delete -a "$APP_NAME" --org "$CPLN_ORG" --yes | ||
|
|
||
| echo "✅ Successfully deleted application: $APP_NAME" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| name: Setup Control Plane Environment | ||
| description: Sets up Ruby, installs the Control Plane CLI and cpflow gem, and configures a default profile | ||
|
|
||
| inputs: | ||
| token: | ||
| description: Control Plane token | ||
| required: true | ||
| org: | ||
| description: Control Plane organization | ||
| required: true | ||
| ruby_version: | ||
| description: Ruby version used for cpflow | ||
| required: false | ||
| default: "3.4.6" | ||
| cpln_cli_version: | ||
| description: "@controlplane/cli version" | ||
| required: false | ||
| default: "3.3.1" | ||
| cpflow_version: | ||
| description: cpflow gem version | ||
| required: false | ||
| default: "5.1.1" | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Set up Ruby | ||
| uses: ruby/setup-ruby@v1 | ||
| with: | ||
| ruby-version: ${{ inputs.ruby_version }} | ||
|
|
||
| - name: Install Control Plane CLI and cpflow gem | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| sudo npm install -g @controlplane/cli@${{ inputs.cpln_cli_version }} | ||
| cpln --version | ||
|
|
||
| gem install cpflow -v ${{ inputs.cpflow_version }} | ||
| cpflow --version | ||
|
|
||
| - name: Setup Control Plane profile and registry login | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| TOKEN="${{ inputs.token }}" | ||
| ORG="${{ inputs.org }}" | ||
|
|
||
| if [[ -z "$TOKEN" ]]; then | ||
| echo "Error: Control Plane token not provided" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ -z "$ORG" ]]; then | ||
| echo "Error: Control Plane organization not provided" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
|
Comment on lines
+51
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dead code: both |
||
| create_output="" | ||
| if ! create_output="$(cpln profile create default --token "$TOKEN" --org "$ORG" 2>&1)"; then | ||
| if ! echo "$create_output" | grep -qi "already exists"; then | ||
| echo "$create_output" >&2 | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| cpln profile update default --org "$ORG" --token "$TOKEN" | ||
| cpln image docker-login --org "$ORG" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| /* eslint-disable max-classes-per-file */ | ||
|
|
||
| 'use client'; | ||
|
|
||
| import React from 'react'; | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor:
$*vs$@in the display messageThe actual
exec "$@"below is correct. But in a double-quoted string,$*joins all positional parameters with the first character ofIFS(usually a space), while$@expands them as separate words. For a display message they behave identically in normal cases, but$@is the more precise choice and consistent with theexecbelow.