{"id":47670988,"url":"https://github.com/jonathanrainer/ghafmt","last_synced_at":"2026-07-12T04:00:49.242Z","repository":{"id":346395481,"uuid":"1181920379","full_name":"jonathanrainer/ghafmt","owner":"jonathanrainer","description":"A formatter for GitHub Actions workflow and action metadata files","archived":false,"fork":false,"pushed_at":"2026-07-04T02:47:49.000Z","size":352,"stargazers_count":4,"open_issues_count":4,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-07-04T04:32:28.361Z","etag":null,"topics":["ci","devtools","formatter","github-actions","github-actions-workflow","rust","workflow","yaml"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonathanrainer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["jonathanrainer"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"thanks_dev":null,"custom":null}},"created_at":"2026-03-14T20:01:52.000Z","updated_at":"2026-07-03T06:36:59.000Z","dependencies_parsed_at":"2026-06-18T02:00:49.416Z","dependency_job_id":null,"html_url":"https://github.com/jonathanrainer/ghafmt","commit_stats":null,"previous_names":["jonathanrainer/ghafmt"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/jonathanrainer/ghafmt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanrainer%2Fghafmt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanrainer%2Fghafmt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanrainer%2Fghafmt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanrainer%2Fghafmt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonathanrainer","download_url":"https://codeload.github.com/jonathanrainer/ghafmt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanrainer%2Fghafmt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35381310,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-12T02:00:06.386Z","response_time":87,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ci","devtools","formatter","github-actions","github-actions-workflow","rust","workflow","yaml"],"created_at":"2026-04-02T12:50:05.603Z","updated_at":"2026-07-12T04:00:49.140Z","avatar_url":"https://github.com/jonathanrainer.png","language":"Rust","funding_links":["https://github.com/sponsors/jonathanrainer"],"categories":[],"sub_categories":[],"readme":"# ghafmt\n\nA formatter for GitHub Actions workflow and action metadata files.\n\n[![CI](https://github.com/jonathanrainer/ghafmt/actions/workflows/code_checks.yml/badge.svg)](https://github.com/jonathanrainer/ghafmt/actions/workflows/code_checks.yml)\n[![License: MIT OR Apache-2.0](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue.svg)](LICENSE)\n\n`ghafmt` enforces a consistent style across your GitHub Actions YAML files — both workflow files and action metadata\nfiles (`action.yml` / `action.yaml`). It reorders keys, sorts blocks alphabetically, inserts blank lines between\nsteps and jobs, and converts IDs to `snake_case` — so code review diffs show only meaningful changes, not formatting\nnoise.\n\n**Workflow formatting rules:**\n\n- Step keys reordered to: `name` → `uses`/`run` → `id` → `with`/`env`\n- Top-level workflow keys sorted (`name` → `on` → `env` → `jobs`)\n- Trigger events, `needs` arrays, `runs-on` arrays, and filter arrays sorted alphabetically\n- Blank lines inserted between top-level keys, jobs, and steps\n- Job IDs and step IDs converted to `snake_case`\n- Keys within `with`, `env`, `permissions`, and similar maps sorted alphabetically\n\n**Action metadata formatting rules (`action.yml` / `action.yaml`):**\n\n- Top-level keys sorted to canonical order: `name` → `description` → `author` → `inputs` → `outputs` → `runs` → `branding`\n- `inputs` and `outputs` sorted alphabetically; per-entry keys sorted idiomatically\n- `runs` keys sorted by action type: composite (`using` → `steps`), JavaScript (`using` → `pre` → `pre-if` → `main` → `post` → `post-if`), Docker (`using` → `image` → `args` → `env` → `pre-entrypoint` → `entrypoint` → `post-entrypoint`)\n- Step keys and `with` maps inside composite action steps sorted alphabetically\n- Step IDs converted to `snake_case`\n- `branding` keys sorted (`icon` → `color`)\n\n## Before / After\n\n**Before:**\n\n```yaml\non:\n  workflow_dispatch:\n  push:\n    branches: [main]\n  pull_request:\nname: CI Pipeline\njobs:\n  RunTests:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n        name: Checkout\n      - with:\n          node-version: '20'\n          cache: npm\n        uses: actions/setup-node@v4\n        name: Setup Node\n      - run: npm install\n        name: Install deps\n        id: install\n      - env:\n          NODE_ENV: test\n          CI: true\n        run: npm test\n        name: Run tests\n        id: testStep\n  BuildAndDeploy:\n    needs: [RunTests]\n    runs-on: ubuntu-latest\n    steps:\n      - name: Build\n        run: npm run build\n      - env:\n          AWS_SECRET_ACCESS_KEY: ${{ secrets.SECRET_KEY }}\n          AWS_ACCESS_KEY_ID: ${{ secrets.ACCESS_KEY }}\n          AWS_REGION: us-east-1\n        run: aws s3 sync dist/ s3://my-bucket\n        name: Deploy\n        id: deployStep\n```\n\n**After:**\n\n```yaml\nname: CI Pipeline\n\non:\n  pull_request:\n  push:\n    branches: [main]\n  workflow_dispatch:\n\njobs:\n  run_tests:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v4\n\n      - name: Setup Node\n        uses: actions/setup-node@v4\n        with:\n          cache: npm\n          node-version: '20'\n\n      - name: Install deps\n        id: install\n        run: npm install\n\n      - name: Run tests\n        id: test_step\n        run: npm test\n        env:\n          CI: true\n          NODE_ENV: test\n\n  build_and_deploy:\n    needs: [run_tests]\n    runs-on: ubuntu-latest\n    steps:\n      - name: Build\n        run: npm run build\n\n      - name: Deploy\n        id: deploy_step\n        run: aws s3 sync dist/ s3://my-bucket\n        env:\n          AWS_ACCESS_KEY_ID: ${{ secrets.ACCESS_KEY }}\n          AWS_REGION: us-east-1\n          AWS_SECRET_ACCESS_KEY: ${{ secrets.SECRET_KEY }}\n```\n\n## Installation\n\n### Pre-built binary\n\nDownload the latest release from [GitHub Releases](https://github.com/jonathanrainer/ghafmt/releases/latest):\n\n```bash\n# Replace \u003cVERSION\u003e and \u003cTARGET\u003e with values from the releases page:\n#   x86_64-unknown-linux-musl  (Linux x86_64)\n#   aarch64-unknown-linux-musl (Linux ARM64)\n#   aarch64-apple-darwin       (macOS Apple Silicon)\n#   x86_64-apple-darwin        (macOS Intel)\ncurl -fsSL https://github.com/jonathanrainer/ghafmt/releases/download/v\u003cVERSION\u003e/ghafmt-\u003cVERSION\u003e-\u003cTARGET\u003e.tar.gz | tar -xz\nsudo mv ghafmt /usr/local/bin/\n```\n\n### Docker\n\n```bash\ndocker pull ghcr.io/jonathanrainer/ghafmt:latest\n```\n\n## Usage\n\n```bash\n# Format to stdout\nghafmt workflow.yml\n\n# Read from stdin\ncat workflow.yml | ghafmt -\n\n# Check formatting without writing (exits non-zero if any file is dirty)\nghafmt --mode=check .github/workflows/\n\n# Write changes in place\nghafmt --mode=write .github/workflows/\n\n# List files that would be changed\nghafmt --mode=list .github/workflows/\n```\n\n### Docker\n\n```bash\ndocker run --rm -v \"$PWD\":/work ghcr.io/jonathanrainer/ghafmt:latest --mode=check /work/.github/workflows/\n```\n\n## CI Integration\n\n### GitHub Actions\n\nUse the bundled action — it downloads the correct pre-built binary for the runner platform and automatically\ndiscovers both workflow files and any `action.yml`/`action.yaml` files in the repository:\n\n```yaml\n- uses: jonathanrainer/ghafmt@6ca7fada15c9e58b3c85a3fa12433ca23eda5b2e # v0.1.5\n  with:\n    mode: check          # check (default) | write | list\n    path: .github/workflows/\n```\n\nOr use the Docker image directly:\n\n```yaml\n- name: Check workflow formatting\n  run: |\n    docker run --rm -v \"$GITHUB_WORKSPACE\":/work \\\n      ghcr.io/jonathanrainer/ghafmt:latest --mode=check /work/.github/workflows/\n```\n\n### CircleCI\n\n```yaml\n- run:\n    name: Check workflow formatting\n    command: |\n      VERSION=$(curl -fsSL https://api.github.com/repos/jonathanrainer/ghafmt/releases/latest | grep tag_name | cut -d'\"' -f4 | sed 's/^v//')\n      curl -fsSL \"https://github.com/jonathanrainer/ghafmt/releases/download/v${VERSION}/ghafmt-${VERSION}-x86_64-unknown-linux-musl.tar.gz\" | tar -xz -C /tmp\n      /tmp/ghafmt --mode=check .github/workflows/\n```\n\n## Pre-commit\n\nAdd to your `.pre-commit-config.yaml` (requires `ghafmt` on `PATH`):\n\n```yaml\nrepos:\n  - repo: local\n    hooks:\n      - id: ghafmt\n        name: ghafmt\n        language: system\n        entry: ghafmt --mode=check\n        pass_filenames: true\n        files: ^(\\.github/workflows/.*\\.ya?ml|(.*\\/)?action\\.ya?ml)$\n```\n\n## Acknowledgements\n\n`ghafmt` is built on top of two foundational projects:\n\n- [**libfyaml**](https://github.com/pantoniou/libfyaml) by [@pantoniou](https://github.com/pantoniou) — the YAML parser and emitter at the core of this tool. [@pantoniou](https://github.com/pantoniou) has been exceptionally generous in reviewing and merging patches to support `ghafmt`'s use case.\n- [**fyaml**](https://github.com/0k/fyaml) by [@0k](https://github.com/0k) — the Rust bindings to libfyaml that make it possible to use from this codebase.\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md).\n\n## License\n\nLicensed under either of [MIT](LICENSE) or [Apache-2.0](LICENSE-APACHE) at your option.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanrainer%2Fghafmt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonathanrainer%2Fghafmt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanrainer%2Fghafmt/lists"}