{"id":13473890,"url":"https://github.com/bltavares/actions","last_synced_at":"2025-04-15T04:23:09.147Z","repository":{"id":52813623,"uuid":"165879713","full_name":"bltavares/actions","owner":"bltavares","description":"Collection of linters and fixers as Github Actions - Alpha","archived":false,"fork":false,"pushed_at":"2022-07-28T13:16:00.000Z","size":394,"stargazers_count":120,"open_issues_count":9,"forks_count":23,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T15:51:47.449Z","etag":null,"topics":["actions","alpha","github-actions"],"latest_commit_sha":null,"homepage":"https://github.com/features/actions","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bltavares.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-15T15:55:04.000Z","updated_at":"2024-05-07T17:46:07.000Z","dependencies_parsed_at":"2022-08-22T20:00:18.014Z","dependency_job_id":null,"html_url":"https://github.com/bltavares/actions","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bltavares%2Factions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bltavares%2Factions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bltavares%2Factions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bltavares%2Factions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bltavares","download_url":"https://codeload.github.com/bltavares/actions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249004622,"owners_count":21196908,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["actions","alpha","github-actions"],"created_at":"2024-07-31T16:01:07.756Z","updated_at":"2025-04-15T04:23:09.115Z","avatar_url":"https://github.com/bltavares.png","language":"Shell","funding_links":[],"categories":["Community Resources","Shell","Uncategorized"],"sub_categories":["Collection of Actions","Uncategorized"],"readme":"# GitHub Actions\n\n![Alpha software](https://img.shields.io/badge/stability-alpha-yellowgreen.svg)\n\nUseful GitHub Actions to help build software.\nDetailed documentation on how to use each action located in their folder.\n\n## Provided actions\n\n### Utilities\n\n\u003c!-- markdownlint-disable MD013 --\u003e\n| Action       | Description                                              |\n|--------------|----------------------------------------------------------|\n| [bash](bash) | Execute any shell command, with some utilities available |\n\u003c!-- markdownlint-enable MD013 --\u003e\n\n### Linters and Formatters\n\n\u003c!-- markdownlint-disable MD013 --\u003e\n| Action                       | Description                   | Lint on Push | Fix with Review   | Autofix on Push   |\n|------------------------------|-------------------------------|--------------|-------------------|-------------------|\n| [clippy](clippy)             | Rust linter                   | x            | x (Partial fixes) | x (Partial fixes) |\n| [cljfmt](cljfmt)             | Clojure formatter             | x            | x                 | x                 |\n| [dartfmt](dartfmt)           | Dart (and Flutter) formatter  | x            | x                 | x                 |\n| [prettier](prettier)         | An opinionated code formatter | x            | x (Partial fixes) | x (Partial fixes) |\n| [pwshfmt](pwshfmt)           | Powershell Formatter          | x            | x                 | x                 |\n| [rubocop](rubocop)           | Ruby linter                   | x            | x                 | x                 |\n| [rustfmt](rustfmt)           | Rust formatter                | x            | x                 | x                 |\n| [shfmt](shfmt)               | Shell formatter               | x            | x                 | x                 |\n| [terraform](terraform)       | Terraform linter              | x            | x                 | x                 |\n| [tslint](tslint)             | TypeScript lint and formatter | x            | x                 | x                 |\n| [yamllint](yamllint)         | YAML linter                   | x            | x                 |                   |\n| [zprint](zprint)             | Clojure formatter             | x            | x                 | x                 |\n| [dartanalyzer](dartanalyzer) | Dart (and Flutter) linter     | x            |                   |                   |\n| [hadolint](hadolint)         | Dockerfile linter             | x            |                   |                   |\n| [kubeval](kubeval)           | Kubernets (k8s) linter        | x            |                   |                   |\n| [mdlint](mdlint)             | Markdown linting              | x            |                   |                   |\n| [shellcheck](shellcheck)     | Bash linter                   | x            |                   |                   |\n\u003c!-- markdownlint-enable MD013 --\u003e\n\n#### Linters on push\n\nAdding linters on the PR is as simple as adding an action to resolve on `push`.\n\nLinters don't need access to `GITHUB_TOKEN`, but they might need extra secrets\nand env-vars, depending on how the tool is used.\n\nFor example, `cljfmt` needs to be installed and setup on the project, as well as\nany environment variable to access the project's dependencies. Meanwhile\n,`shellcheck` needs no modification on the project to be adopted.\n\nCheck the documentation of the action to see if it is necessary to setup the\nproject before adoption.\n\nHere is an example workflow:\n\n```hcl\nworkflow \"on push\" {\n  on = \"push\"\n  resolves = [\"shellcheck\"]\n}\n\naction \"shellcheck\" {\n  uses = \"bltavares/actions/shellcheck@master\"\n}\n```\n\n#### Fixes by Review comments\n\nIt is possible to add linters which observe the Review comments and act upon\nthem. This uses the `pull_request_review` event, and it expects the `fix\n\u003caction\u003e` as the content.\n\nGiven this workflow, you could trigger the fix as the following:\n\n```hcl\nworkflow \"on reviews\" {\n  on = \"pull_request_review\"\n  resolves = [\"cljfmt\"]\n}\n\naction \"cljfmt\" {\n  uses = \"bltavares/actions/cljfmt@master\"\n  secrets = [\"GITHUB_TOKEN\"]\n}\n```\n\n![Example: fix using review comment](./docs/fix-using-review-comment.png)\n\nThe event **only** works on Review comments, not on regular PR comments.\n\nThis is a limitation of the information provided on the event payload, which\nReview comments are run on the PR context, while regular comments on the PR are\nrun pointing to `master`, with no reference to the branch being discussed.\n\n_(So far I'm not aware how to make it work for both scenarios with the\ninformation provided)_\n\n#### Autofixing\n\nIt is possible to add linters which will automatically fix itself. It does so by\nusing the underlying autofix, commiting and running the lints right after.\n\nRunning a second time allows the check to validate if the automatic changes\nfixed all the warnings, as some warnings cannot be automated by the underlying\ntool.\n\nAutofixing can be enabled by passing the `autofix` argument using `args = [\"autofix\"]`.\nBy default the github `push` event is used.\n\n```hcl\nworkflow \"on reviews\" {\n  on = \"pull_request_review\"\n  resolves = [\"shfmt\"]\n}\n\naction \"shfmt\" {\n  uses = \"bltavares/actions/shfmt@master\"\n  args = [\"autofix\"]\n  secrets = [\"GITHUB_TOKEN\"]\n}\n```\n\nThe github event can be configured via the `AUTOFIX_EVENTS` env variable.\nFollowing example uses the `pull_request` event, instead of `push`.\n\n```hcl\nworkflow \"on reviews\" {\n  on = \"pull_request_review\"\n  resolves = [\"shfmt\"]\n}\n\naction \"shfmt\" {\n  uses = \"bltavares/actions/shfmt@master\"\n  args = [\"autofix\"]\n  env = {\n    AUTOFIX_EVENTS=\"pull_request|push\"\n  }\n  secrets = [\"GITHUB_TOKEN\"]\n  needs = [\"action-filter\"]\n}\n\naction \"action-filter\" {\n  uses = \"actions/bin/filter@master\"\n  args = \"action 'opened|ready_for_review|synchronize'\"\n}\n```\n\nAs the `pull_request` event is rather chatty it is recommended to apply action filters.\n\n##### :warning: Caveats\n\nAutofixes requires a certain level of coordination when building the workflow.\nGiven that each action runs and modify the code, they need to be sequential,\notherwise a data race might lead to lost commits.\n\nThe _autofixers_ might run in parallel of other linters, but not in parallel of\nother autofixers.\n\nHere is an example of how to chain fixers on a workflow, while still having\nparallel linters running.\n\n```hcl\nworkflow \"on push\" {\n  on = \"push\"\n  resolves = [\"linters\", \"autofixers\"]\n}\n\naction \"linters\" {\n  needs = [\"mdlint\", \"shellcheck\"]\n  uses = \"actions/bin/sh@master\"\n  args = [\"echo Linters ok\"]\n}\n\naction \"autofixers\" {\n  needs = [\"shfmt\", \"cljfmt\"]\n  uses = \"actions/bin/sh@master\"\n  args = [\"echo Fixers ok\"]\n}\n\naction \"shfmt\" {\n  uses = \"bltavares/actions/shfmt@master\"\n  args = [\"autofix\"]\n  secrets = [\"GITHUB_TOKEN\"]\n  needs = [\"cljfmt\"]\n}\n\naction \"cljfmt\" {\n  uses = \"bltavares/actions/cljfmt@master\"\n  args = [\"autofix\"]\n  secrets = [\"GITHUB_TOKEN\"]\n}\n\naction \"mdlint\" {\n  uses = \"bltavares/actions/mdlint@master\"\n}\n\naction \"shellcheck\" {\n  uses = \"bltavares/actions/shellcheck@master\"\n}\n```\n\nThis would generate the following pipeline:\n\n![Autofixer visual pipeline](docs/autofixer-visual-pipeline.png)\n\nAnd would result on the following example on pushes:\n\n![Autofixer commit example](docs/autofixer-commit-example.png)\n\nYou may validate the ordering of fixers using `act -l` locally, provided by\n[nektos/act](https://github.com/nektos/act).\n\n#### Restricting execution of autofixers on push\n\nAutofixers listening to `push` events will execute both on pull requests,\nas well as commits pointing to master. If there is no restriction, on master commits\nthe autofixers will also commit the changes to master.\n\nThis might not be the workflow you are looking for. You may use\n[actions/bin/filter](https://github.com/actions/bin/tree/master/filter) to restrict\nwheter autofixers should run or not, leveraing the [ref filter](https://github.com/actions/bin/tree/master/filter#ref)\nand [branch filter](https://github.com/actions/bin/tree/master/filter#branch)\n\nHere is one example, using autofixers only on PRs, while using them as linters\non master.\n\n```hcl\nworkflow \"on push\" {\n  on = \"push\"\n  resolves = [\"linters\", \"autofixers\"]\n}\n\naction \"linters\" {\n  needs = [\"mdlint\", \"shellcheck\", \"shfmt-lint\", \"cljfmt-lint\"]\n  uses = \"actions/bin/sh@master\"\n  args = [\"echo Linters ok\"]\n}\n\naction \"autofixers\" {\n  needs = [\"shfmt\", \"cljfmt\"]\n  uses = \"actions/bin/sh@master\"\n  args = [\"echo Fixers ok\"]\n}\n\naction \"pr filter\" {\n  uses = \"actions/bin/filter@master\"\n  args = \"ref refs/pulls/*\"\n}\n\naction \"master filter\" {\n  uses = \"actions/bin/filter@master\"\n  args = \"branch master\"\n}\n\naction \"fixers-lint\" {\n  uses = \"actions/bin/filter@master\"\n  args = \"branch master\"\n}\n\naction \"shfmt\" {\n  uses = \"bltavares/actions/shfmt@master\"\n  args = [\"autofix\"]\n  secrets = [\"GITHUB_TOKEN\"]\n  needs = [\"cljfmt\", \"pr filter\"]\n}\n\naction \"cljfmt\" {\n  uses = \"bltavares/actions/cljfmt@master\"\n  args = [\"autofix\"]\n  secrets = [\"GITHUB_TOKEN\"]\n  needs = [\"pr filter\"]\n}\n\naction \"shfmt-lint\" {\n  uses = \"bltavares/actions/shfmt@master\"\n  needs = [\"master filter\"]\n}\n\naction \"cljfmt-lint\" {\n  uses = \"bltavares/actions/cljfmt@master\"\n  needs = [\"master filter\"]\n}\n\naction \"mdlint\" {\n  uses = \"bltavares/actions/mdlint@master\"\n}\n\naction \"shellcheck\" {\n  uses = \"bltavares/actions/shellcheck@master\"\n}\n```\n\n## Running locally\n\nIt is possible to test the actions and execute locally using\n[nektos/act](https://github.com/nektos/act).\n\nIf the workflow contains **linters**, they will execute on the same context as\nGitHub Actions would, allowing to use them as a quick feedback tool.\n\nAlternatively, if **autofixers** are present on your project workflow, not only\nthey will execute the linter, but it will commit and push their fixes from your\nmachine as well.\n\n:warning: Autofixers will commit any dirty tree state if run locally. Only run\nthem on clean branches if you want to keep the git history clean.\n\nThis make them effective pre-commit hooks that either run remotely or locally.\n\n## Building this repo\n\nThis project uses [nektos/act](https://github.com/nektos/act) to test changes\nlocally, and requires it to be installed.\n\nTo keep all the `lib.sh` updated and validate the project itself, run:\n\n```bash\nmake\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbltavares%2Factions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbltavares%2Factions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbltavares%2Factions/lists"}