From 1d6bd58a80b2d114e302a966754b3156778b1f48 Mon Sep 17 00:00:00 2001 From: kyle Date: Thu, 12 Feb 2026 22:09:29 -0600 Subject: [PATCH 1/2] updates --- README.md | 101 ++++++++++++++++++++++++-- action.sh | 3 + action.yml | 1 + tests/full-run.bats | 3 + tests/snapshots/full-run.expected.txt | 7 +- 5 files changed, 107 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ba0ff3a..ac09da8 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,104 @@ # Print Workflow Data -Prints most of the data from the `github` object, as well as matrix context, job context, runner context, and optionally passed inputs, needs, and vars from the caller. +Composite action that prints GitHub Actions context data for debugging. Outputs formatted, color-coded sections for github, matrix, job, runner contexts, plus optional caller-provided data. -See [github documentation](https://docs.github.com/en/actions/reference/workflows-and-actions/contexts) for information about each context and what certain values may mean. +Designed to run at the top of a workflow. Swallows errors to not fail workflows. -## example usage: +## Usage + +```yaml +- uses: hwrok/print-workflow-data@v1 +``` + +### With optional inputs ```yaml - uses: hwrok/print-workflow-data@v1 with: - caller-inputs: ${{ toJSON(inputs) }} # optional - caller-needs: ${{ toJSON(needs) }} # optional - caller-vars: ${{ toJSON(vars) }} # optional + caller-inputs: ${{ toJSON(inputs) }} + caller-needs: ${{ toJSON(needs) }} + caller-vars: ${{ toJSON(vars) }} + extras: ${{ toJSON(matrix) }} ``` + +## Inputs + +| Input | Description | Required | +| --------------- | ------------------------------------------------ | -------- | +| `caller-inputs` | Workflow inputs — `${{ toJSON(inputs) }}` | No | +| `caller-needs` | Job dependency results — `${{ toJSON(needs) }}` | No | +| `caller-vars` | Repository/org variables — `${{ toJSON(vars) }}` | No | +| `extras` | Any additional data, ideally as `toJSON(...)` | No | + +## Output + +JSON objects are automatically formatted as aligned key-value tables (requires `jq` on the runner, falls back to raw JSON otherwise). + +``` +┌────────────────┐ +│ github context │ +└────────────────┘ +github.repository : org/repo +github.actor : some_user +github.triggering_actor : some_user +github.job : build +github.workflow : Build and Test +github.workflow_ref : org/repo/.github/workflows/build.yml@refs/heads/main +github.run_id : 123456789 +github.run_number : 42 +github.run_attempt : 1 +github.event_name : push +github.event.action : +github.event.pr_number : +github.base_ref : +github.head_ref : +is_default_branch : true +is_default_target : false +github.ref : refs/heads/main +github.ref_name : main +github.sha : abc1234def5678 +┌────────────────┐ +│ matrix context │ +└────────────────┘ +n/a +┌─────────────┐ +│ job context │ +└─────────────┘ +check_run_id : 63441063310 +status : success +┌────────────────┐ +│ runner context │ +└────────────────┘ +arch : X64 +environment : github-hosted +name : runner-1 +os : Linux +┌───────────────┐ +│ caller inputs │ +└───────────────┘ +n/a +┌──────────────┐ +│ caller needs │ +└──────────────┘ +n/a +┌─────────────┐ +│ caller vars │ +└─────────────┘ +n/a +┌────────┐ +│ extras │ +└────────┘ +n/a +``` + +Section headers are color-coded green in the actual workflow logs. Sections with no data display `n/a`. + +## Notes + +- `caller-vars` exposes repository/org-level variables. Generally safe unless secrets have been stored as variables instead of secrets. +- `extras` accepts any string, but `toJSON(...)` format gets the nicest output. +- The action uses `continue-on-error: true` and `exit 0` — it will never fail a calling workflow. + +## License + +MIT diff --git a/action.sh b/action.sh index 3bfb058..38094fc 100755 --- a/action.sh +++ b/action.sh @@ -51,8 +51,10 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then [ "$GITHUB_BASE_REF" = "$DEFAULT_BRANCH" ] && is_default_target="true" github_context_body=$(cat < Date: Thu, 12 Feb 2026 22:14:38 -0600 Subject: [PATCH 2/2] updates --- .github/workflows/pr.yml | 4 ++-- action.yml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 4cf74f0..f3c18d7 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -9,11 +9,11 @@ jobs: name: validate runs-on: ubuntu-latest steps: - - uses: hwrok/print-workflow-data@v1 - - name: checkout uses: actions/checkout@v6 + - uses: ./ + - name: pnpm uses: pnpm/action-setup@v4 with: diff --git a/action.yml b/action.yml index e3363f7..c4c82e6 100644 --- a/action.yml +++ b/action.yml @@ -7,15 +7,15 @@ branding: inputs: caller-inputs: - description: '`caller-inputs: ${{ toJSON(inputs) }}`' + description: 'workflow inputs as toJSON(inputs)' required: false default: '' caller-needs: - description: '`caller-needs: ${{ toJSON(needs) }}`' + description: 'job dependency results as toJSON(needs)' required: false default: '' caller-vars: - description: 'pass via `caller-vars: ${{ toJSON(vars) }}` (generally safe unless secrets have been mismanaged)' + description: 'repository/org variables as toJSON(vars) — generally safe unless secrets have been mismanaged' required: false default: '' extras: