Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
| `mode` | Workflow mode ('check' or 'fix') | false | `check` |
| `ref` | Manual ref override | false | |
| `repo` | Manual repo override | false | |
| `sha` | Full immutable source SHA; caller-approved SHA required for comments | false | |
| `pr-base-sha` | Manual base SHA override (check mode only) | false | |
| `checkout-path` | Manual checkout path override | false | |
| `build-path` | Manual build path override | false | |
Expand All @@ -31,13 +32,24 @@
|------|-------------|
| `is_act` | Whether running in act |
| `ref` | Resolved ref |
| `sha` | Validated immutable source SHA, separate from the push ref |
| `repo` | Resolved repository |
| `base_sha` | Resolved base SHA |
| `pr_number` | PR number |
| `checkout_path` | Resolved checkout path |
| `build_path` | Resolved build path |
| `has_changes` | Whether relevant changes were detected |

## Immutable-source integration

Consumers must use `sha` for source checkout, builds, formatting, artifact production, and privileged consumption; retain `ref` only as the branch push destination. Issue-comment callers must authorize the exact repository and SHA before invoking this action. Missing approval or a moved/mismatched PR snapshot fails closed, including explicit `format-all` overrides. A current-head lookup does not authenticate the reviewer or prove comment-time approval. Commit timestamps are not used. `head-ref`, when supplied, must equal the snapshot. Unknown modes, invalid nested outputs, and escaping/overlapping paths are rejected.

The currently pinned preparation releases do not expose SHA. This action therefore validates their metadata and resolves/compares the immutable snapshot itself, then passes that SHA through the **existing** `ref` and `head-ref` inputs of the pinned change-detection action. It does not invent release SHAs or pass unsupported inputs to old pins. Once the new preparation releases are published, a reviewed follow-up must update their pins and forward the `sha` input/output through them. The pinned change detector still needs its own reviewed update for true empty sparse checkout and filename-output hardening. Those transitive mitigations are not deployed by changing this wrapper alone.

All reusable `format-all` and individual jobs must carry one `repo`/`ref`/`sha` tuple. Supply `sha` to `handle-fix-commit` as `pr-info-sha`; branch movement must produce a patch or require renewed approval, not an automatic rebase. Local action changes require reviewed releases and consumer-pin updates before Phlex adopts them.

Snapshot policy, preflight checks, and tests use Python 3.12 or newer with no third-party Python client or local Node requirement. Python runs in isolated mode to ignore target-controlled import configuration. The small standard-library API adapter makes bounded GET requests to the runner's configured HTTPS GitHub endpoint, rejects redirects, and exposes lookup failures without falling back to another snapshot.

## License

[Apache 2.0](LICENSE)
61 changes: 33 additions & 28 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ inputs:
repo:
description: "Manual repo override"
required: false
sha:
description: "Full immutable source SHA; caller-approved SHA required for issue comments"
required: false
pr-base-sha:
description: "Manual base SHA override (check mode only)"
required: false
Expand Down Expand Up @@ -40,6 +43,9 @@ outputs:
ref:
description: "Resolved ref"
value: ${{ steps.prepare.outputs.ref }}
sha:
description: "Validated immutable source SHA, separate from ref"
value: ${{ steps.prepare.outputs.sha }}
repo:
description: "Resolved repository"
value: ${{ steps.prepare.outputs.repo }}
Expand All @@ -62,6 +68,18 @@ outputs:
runs:
using: "composite"
steps:
- name: Validate inputs before nested resolution
shell: bash
env:
INPUT_MODE: ${{ inputs.mode }}
INPUT_SHA: ${{ inputs.sha }}
INPUT_REF: ${{ inputs.ref }}
INPUT_REPO: ${{ inputs.repo }}
INPUT_PR_BASE_SHA: ${{ inputs.pr-base-sha }}
INPUT_CHECKOUT_PATH: ${{ inputs.checkout-path }}
INPUT_BUILD_PATH: ${{ inputs.build-path }}
run: |
python3 -I "$GITHUB_ACTION_PATH/standardize_outputs.py" --validate
- name: Prepare basic outputs (check mode)
if: inputs.mode == 'check'
id: prepare_check
Expand All @@ -86,8 +104,15 @@ runs:
id: prepare
shell: bash
env:
GITHUB_TOKEN: ${{ github.token }}
INPUT_MODE: ${{ inputs.mode }}
INPUT_SHA: ${{ inputs.sha }}
INPUT_REF: ${{ inputs.ref }}
INPUT_REPO: ${{ inputs.repo }}
INPUT_PR_BASE_SHA: ${{ inputs.pr-base-sha }}
INPUT_CHECKOUT_PATH: ${{ inputs.checkout-path }}
INPUT_BUILD_PATH: ${{ inputs.build-path }}
INPUT_HEAD_REF: ${{ inputs.head-ref }}
CHECK_IS_ACT: ${{ steps.prepare_check.outputs.is_act }}
CHECK_REF: ${{ steps.prepare_check.outputs.ref }}
CHECK_REPO: ${{ steps.prepare_check.outputs.repo }}
Expand All @@ -99,42 +124,21 @@ runs:
FIX_REPO: ${{ steps.prepare_fix.outputs.repo }}
FIX_CHECKOUT_PATH: ${{ steps.prepare_fix.outputs.checkout_path }}
run: |
if [ "${INPUT_MODE}" == "check" ]; then
echo "is_act=${CHECK_IS_ACT}" >> "$GITHUB_OUTPUT"
echo "ref=${CHECK_REF}" >> "$GITHUB_OUTPUT"
echo "repo=${CHECK_REPO}" >> "$GITHUB_OUTPUT"
echo "base_sha=${CHECK_BASE_SHA}" >> "$GITHUB_OUTPUT"
echo "pr_number=${CHECK_PR_NUMBER}" >> "$GITHUB_OUTPUT"
echo "checkout_path=${CHECK_CHECKOUT_PATH}" >> "$GITHUB_OUTPUT"
echo "build_path=${CHECK_BUILD_PATH}" >> "$GITHUB_OUTPUT"
else
echo "is_act=false" >> "$GITHUB_OUTPUT"
echo "ref=${FIX_REF}" >> "$GITHUB_OUTPUT"
echo "repo=${FIX_REPO}" >> "$GITHUB_OUTPUT"
echo "base_sha=" >> "$GITHUB_OUTPUT"
echo "pr_number=$(jq -r '.issue.number // empty' "${GITHUB_EVENT_PATH}")" >> "$GITHUB_OUTPUT"
echo "checkout_path=${FIX_CHECKOUT_PATH}" >> "$GITHUB_OUTPUT"
REPO_NAME="${FIX_CHECKOUT_PATH%-src}"
BUILD_PATH="${INPUT_BUILD_PATH}"
if [ -z "$BUILD_PATH" ]; then
BUILD_PATH="${REPO_NAME}-build"
fi
echo "build_path=$BUILD_PATH" >> "$GITHUB_OUTPUT"
fi
python3 -I "$GITHUB_ACTION_PATH/standardize_outputs.py"

- name: Run change detection
id: detect
if: (inputs.file-type != '' || inputs.include-globs != '') && steps.prepare.outputs.is_act != 'true'
uses: Framework-R-D/action-run-change-detection@047250bcbe1be9fb479c8f3ceeb85ac1084ede2e # v2
with:
checkout-path: ${{ steps.prepare.outputs.checkout_path }}
ref: ${{ steps.prepare.outputs.ref }}
ref: ${{ steps.prepare.outputs.sha }}
repo: ${{ steps.prepare.outputs.repo }}
base-ref: ${{ steps.prepare.outputs.base_sha }}
file-type: ${{ inputs.file-type }}
include-globs: ${{ inputs.include-globs }}
exclude-globs: ${{ inputs.exclude-globs }}
head-ref: ${{ inputs.head-ref }}
head-ref: ${{ steps.prepare.outputs.sha }}

- name: Set has_changes output
id: changes
Expand All @@ -146,14 +150,15 @@ runs:
DETECT_HAS_CHANGES: ${{ steps.detect.outputs.has_changes }}
run: |
if [ "${IS_ACT}" = "true" ] && \
([ "${INPUT_FILE_TYPE}" != "" ] || [ "${INPUT_INCLUDE_GLOBS}" != "" ]); then
{ [ "${INPUT_FILE_TYPE}" != "" ] || [ "${INPUT_INCLUDE_GLOBS}" != "" ]; }; then
echo "has_changes=true" >> "$GITHUB_OUTPUT"
elif [ "${INPUT_FILE_TYPE}" = "" ] && [ "${INPUT_INCLUDE_GLOBS}" = "" ]; then
echo "has_changes=true" >> "$GITHUB_OUTPUT"
else
if [ -z "${DETECT_HAS_CHANGES}" ]; then
echo "has_changes=false" >> "$GITHUB_OUTPUT"
else
if [ "${DETECT_HAS_CHANGES}" = 'true' ] || [ "${DETECT_HAS_CHANGES}" = 'false' ]; then
echo "has_changes=${DETECT_HAS_CHANGES}" >> "$GITHUB_OUTPUT"
else
echo '::error::Change detection did not return a validated boolean.'
exit 1
fi
fi
Loading
Loading