๐บ๐ธ English ย โ ย ๐ฏ๐ต ๆฅๆฌ่ช็ ย โ ย ๐จ๐ณ ็ฎไฝไธญๆ็
ghx runs GitHub Actions workflow as a batch script on Windows, macOS and Linux.
- Matrix Expansion: preview and run every combo or keep only the first for speed.
- Bash to CMD Conversion: Windows or bash, no tweaks needed.
dnx ghx -- dry my-workflowdotnet tool install -g ghxRun by ghx: GitHub workflow eXecute
ghx new my-workflow # create new workflow
ghx dry my-workflow # dry run (prints generated script)
ghx my-workflow --once # run only the first matrix combinationSynopsis:
ghx [command] [options] <workflow-file>run: writes a temp script file and execute. (default)dry: prints run stepsnew: creates a workflow file under.github/workflows(uses.github/ghx_template.yml|.yamlif present)sleep: pauses for the given seconds (supports fractional seconds)
--cmd: emit Windowscmd.exe-formatted output (default on Windows only; on macOS/Linux, use withdryto preview only).--wsl: force bash-compatible output; conflicts with--cmd.--once/-1: keep only the first matrix combination per job (skips the rest).workflow-file: required, must be the file name only (no paths). Resolves to.github/workflows/<name>.yml|.yamlrelative to the current directory.
Create a new workflow:
ghx new test # creates .github/workflows/test.ymlTip
If .github/ghx_template.yml or .github/ghx_template.yaml exists at the repo root, that file is copied verbatim; otherwise the default stub is used.
Edit template:
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_call:
workflow_dispatch:
jobs:
test:
# Basic bash-to-cmd conversion is supported
# See Technical Notes for further information
runs-on: ubuntu-latest
# Matrix expansion is supported
strategy:
matrix:
configuration: [Debug, Release]
# 'uses' are completely ignored
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
with:
dotnet-version: 10.x.x
# Collects all 'run' steps from workflow file
- name: Test
run: |
dotnet restore ./src
dotnet build ./src \
--no-restore \
-c ${{ matrix.configuration }}
# Multiple jobs are supported
other_job:
...From a repo root with .github/workflows/test.yml present, quickly inspect what will run:
ghx dry testTrial-run the same workflow locally with matrix expansion collapsed to a single combination:
ghx run test --onceOn Windows, force cmd.exe formatting or override it to emit bash-compatible scripts:
ghx run test --cmd # default on Windows
ghx run test --wsl # force bash via WSL/bash even on WindowsHere shows GitHub Actions composite sample that uses reusable test workflow.
name: ci
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
jobs:
test:
uses: ./.github/workflows/test.yml # ๐๐๐
# Subsequent job depending on 'test' result
build:
needs: test
if: ${{ !failure() }}
runs-on: ubuntu-latest
steps:
- uses: ...Tip
Reusable workflow cannot be used in conjunction with steps.
| Feature | Support Level | Notes |
|---|---|---|
workflow_call trigger |
โ Full | Primary use case; workflow_dispatch also works |
| Input definitions | โ Full | Type declarations ignored; defaults required if referenced |
| Matrix strategies | โ Full | Cartesian product expansion; --once flag available |
| Multiple jobs | โ Full | Sequential execution; no parallelization or environment isolation |
| Run steps | โ Full | Only run: blocks extracted; uses: actions ignored |
| Placeholder expressions | ${{ inputs.* }} and ${{ matrix.* }} supported; others unsupported |
|
| Bash scripts | โ Full | Default shell; cross-platform with conversion |
| Custom shells | โ None | shell: property causes error |
| Runners | Only ubuntu-latest executed; others display warning |
|
| Positional parameters | $0-$9 converted to %0-%9 for CMD |
|
| Sleep commands | โ Full | sleep N โ ghx sleep N |
- Placeholder values for
inputs.*andmatrix.*are pulled from defaults/matrix entries and quoted as needed. - Any
>> $GITHUB_STEP_SUMMARYor> $GITHUB_STEP_SUMMARYredirections are removed from generated commands. - Inline comments (
# ...) inrunsteps are stripped before processing. - Steps cannot specify a custom
shell; the tool only supports the default shell for the selected output format and will error if a step setsshell. - Bash-to-cmd conversion replaces trailing
\with^, prependsCALL(since many tools ship as.bat/.cmd), and appends a failure guard to mimicbash -ebehavior on Windows. sleep <n>lines inside run blocks becomeghx sleep <n>; fractional durations are supported.- During cmd conversion, positional placeholders
$0โ$9inrunsteps become%0โ%9(only single-digit positions are supported). - Workflow
inputs.*may omit defaults, but if a run step references one without a default, the tool fails fast. - Multiple jobs are supported, but they share process state; no environment reset happens between jobs.
- Jobs are executed sequentially; a job starts only after all matrix combinations from the previous job finish.
- Expands matrix combinations (optional
--onceto keep only the first). - Matrix handling is basic: only simple axes arrays are supported (no
include/exclude/fail-fast/max-parallelor nested objects). - Generates
bashor Windowscmd-formatted scripts.
TODO
- Environment variables: support local
.envfile and${{ env.* }}expansion -i/--input key=value: Ability to overrideinputsofworkflow_call(allow multiple)--step-summary <path>: Instead of removing redirections, set custom output path for.$*and$@conversion:%*exists in cmd but it is not complete equivalent. ("$@"is equivalent to%*; quote required)runs-on: Due to bash to cmd conversion is only supported, it doesn't accept rather thanubuntu-latest.- Native AOT Support: Some report found that
VYamlcan be compiled with Native AOT enabled.