{"id":20523362,"url":"https://github.com/niceguyit/taskfiles","last_synced_at":"2026-03-19T16:14:52.858Z","repository":{"id":156529036,"uuid":"631308437","full_name":"NiceGuyIT/taskfiles","owner":"NiceGuyIT","description":"A collection of task files for use with task","archived":false,"fork":false,"pushed_at":"2023-09-06T22:40:13.000Z","size":177,"stargazers_count":3,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-04T00:30:17.314Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"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/NiceGuyIT.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-22T15:56:34.000Z","updated_at":"2025-08-08T13:23:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"d6665f13-10a1-4941-957c-b6f4c17a736b","html_url":"https://github.com/NiceGuyIT/taskfiles","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/NiceGuyIT/taskfiles","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NiceGuyIT%2Ftaskfiles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NiceGuyIT%2Ftaskfiles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NiceGuyIT%2Ftaskfiles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NiceGuyIT%2Ftaskfiles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NiceGuyIT","download_url":"https://codeload.github.com/NiceGuyIT/taskfiles/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NiceGuyIT%2Ftaskfiles/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29442332,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T07:24:13.446Z","status":"ssl_error","status_checked_at":"2026-02-14T07:23:58.969Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-11-15T22:39:21.872Z","updated_at":"2026-02-14T10:02:37.787Z","avatar_url":"https://github.com/NiceGuyIT.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Taskfiles\n\nA collection of task files for use with [task][]. There's a repo that has [advanced examples][].\n\n[task]: https://github.com/go-task/task\n\n[advanced examples]: https://gitlab.com/megabyte-labs/common/shared/-/tree/master/.config/taskfiles\n\n## Goals\n\nThis project strives to make it easy to run tasks while maintaining a minimal impact to the system. These guidelines are\nused to achieve this goal.\n\n1. Minimal requirements to bootstrap the system.\n2. Only single binary tools are used. This usually means tools that are written in Rust or Go.\n3. Cross-platform support.\n4. If possible, configuration values are passed via environmental variables.\n5. Streaming is preferred over temporary files.\n\n## Requirements\n\nThe following programs are needed to download and uncompress files.\n\n| OS          | Program    | Purpose                                                   |\n|-------------|------------|-----------------------------------------------------------|\n| Linux/macOS | curl       | Download files from the web                               |\n| Linux/macOS | tar        | Extract '.tar.gz' files                                   |\n| Linux/macOS | gunzip     | gunzip '.tar.gz' files                                    |\n| Linux/macOS | unzip      | unzip '.zip' files                                        |\n| Windows     | PowerShell | 'Invoke-WebRequest' cmdlet to download files from the web |\n| Windows     | PowerShell | 'Expand-Archive' cmdlet to unzip files                    |\n| All*        | git        | Required to `git clone` this repo.                        |\n\n\u003e **Note**\n\u003e\n\u003e In the future it may be possible to download and uncompress a release, alleviating the need for `git`.\n\n\u003e **Note 2**\n\u003e\n\u003e Note: [rc-zip][] may be added in the future to allow unzipping from a stream.\n\n[rc-zip]: https://github.com/fasterthanlime/rc-zip\n\n## Install\n\nFollow these steps to bootstrap the system. Actual commands are given below.\n\n1. Clone this repo.\n2. Download [task][] into the current directory.\n3. Run `./task init:all` to create the `bin` directory and download the bare minimum.\n4. Add the `bin` directory to your path.\n    - If `task` is run with elevated permissions, the `bin` directory will be a system-side bin directory.\n    - If `task` is run by a regular user, the `bin` directory will be in their home directory.\n    - `export BIN_DIR=.` to use the current directory. `BIN_DIR` can be set to any directory.\n\n| OS      | User                 | `bin` directory              |\n|---------|----------------------|------------------------------|\n| Linux   | root                 | `/usr/local/bin`             |\n| Linux   | user                 | `$HOME/bin`                  |\n| macOS   | root                 | `/usr/local/bin`             |\n| macOS   | user                 | `$HOME/bin`                  |\n| Windows | Elevated Permissions | `%ProgramData\\taskfiles\\bin` |\n| Windows | user                 | `%USERPROFILE%\\bin`          |\n\n### *nix (Linux/macOS)\n\n\u003cdetails\u003e\n  \u003csummary\u003eInstall taskfiles on Linux/macOS\u003c/summary\u003e\n\n```bash\ngit clone https://github.com/NiceGuyIT/taskfiles\ncd taskfiles\n\n# Download task\nos=$(uname -s | tr '[:upper:]' '[:lower:]')\narch=$(uname -m | sed 's/x86_/amd/')\nrepo=\"https://github.com/go-task/task/releases/latest/download/task_${os}_${arch}.tar.gz\"\ncurl --location --output - \"$repo\" | tar -zxf - task\nchmod a+x ./task\n\n# Initialize the tasks. This downloads 'task' to the bin directory.\n./task init:all\n\n# Cleanup\nrm ./task\n```\n\n\u003c/details\u003e\n\n### Windows\n\nNote: Installing git is outside the scope.\n\n\u003cdetails\u003e\n  \u003csummary\u003eInstall taskfiles on Windows\u003c/summary\u003e\n\n```PowerShell\ngit clone https://github.com/NiceGuyIT/taskfiles\ncd taskfiles\n\n# Download task\n$os = \"windows\"\n$arch = \"amd64\" # 32-bit not supported\n$repo_url = \"https://github.com/go-task/task/releases/latest/download/task_${os}_${arch}.zip\"\n$tmp_file = New-TemporaryFile\nRemove-Item -Path $tmp_file\n$tmp_dir = New-Item -ItemType Directory -Path $( Join-Path -Path $ENV:Temp -ChildPath $tmp_file.Name )\n$zip_file = Join-Path -Path $tmp_dir -ChildPath \"task.zip\"\n$ProgressPreference = \"SilentlyContinue\"\nInvoke-WebRequest -URI $repo_url -OutFile $zip_file\nExpand-Archive -Path $zip_file -DestinationPath $tmp_dir\n$task = Join-Path -Path $tmp_dir -ChildPath \"task.exe\"\n\n# Initialize the tasks. This downloads 'task' to the bin directory.\n\u0026 $task init:all\n\n# Cleanup\nRemove-Item -Path $tmp_dir -Recurse\n```\n\n\u003c/details\u003e\n\n## System specific tasks\n\n- [Tactical RMM][]\n\n[Tactical RMM]: trmm/README.md\n\n## Tasks\n\n`task` uses Go templates to interpret variable names, including environmental variables. The environmental\nvariable `NAME` is written as `{{.NAME}}` in the template. The `{{` and `}}` denote the start and end of the template.\nThe period refers to the variable name; without the period it refers to a function name. For example, `{{.ARCH}}` is\nthe variable that holds the architecture, while `{{ARCH}}` is a function provided by `task` and returns the\narchitecture. Since curly braces are part of the YAML syntax, they need to be enclosed in quotes or used in a text\nblock.\n\nIn the documentation, names refer to variable names, `NAME`, not the Go template name `{{.NAME}}`.\n\n### Including tasks, subdirectories and deps, preconditions and cmds\n\nNote: This is my understanding of how `task` works. I could be wrong and will update this as I learn more.\n\nTo understand how to call or depend on a task in another file, you need to first understand the limitations or drawbacks\nof task.\n\n- `task` does not output if a `task`, `deps`, or `precondition` is not found or invalid. This makes troubleshooting\n  difficult.\n- In order to call tasks in other files, call from the main namespace `:parent:task`.\n- To get the output of a task into a variable, use the dynamic version of variable assignment by using `sh` and\n  calling the task executable. For example, `task namespace:task-name VALUE=\"some value\"`. See [issue #178][].\n    - This format does not work for `deps` since it expects a \"task\", not \"shell output\".\n    - This format does not work for `preconditions` when the goal is to run the task if it needs to. For example, if the\n      task is to download a utility, checking for the existence of the binary will cause the task to fail. The\n      workaround is to add the task to the `cmds` list.\n- Adding the task as another `cmd` in the `cmds` list works even though it goes against the design concepts of task.\n    - Adding the task can be done with `task: :namespace:task-name`.\n- Go templates' `{{` and `}}` have to be quoted in yaml, forcing the value to be interpreted as a string.\n- Use `base64` to pass JSON between tasks, so you don't have to worry about quoting.\n- Variables are interpolated _before_ includes are read. See [issue #454][].\n- Vars declared in the [included Taskfile][] have preference over the variables in the including Taskfile!\n  If you want a variable in an included Taskfile to be overridable, use the default function:\n  `MY_VAR: '{{.MY_VAR | default \"my-default-value\"}}'`\n- Since vars are expanded and env is not, and considering included vars take precedent over including vars, it's\n  advisable to set global environmental variables as global variables in the main Taskfile, and then assign the\n  environmental variable in the task using the global variable. This provides the ability to change the variable in the\n  included (child) Taskfile.\n- Global variables do not have access to global environmental variables declared as \"\"\n\nVars are expanded for Env but Env is not expanded for Vars.\nThis will work:\n\n```yaml\ntasks:\n  task-name:\n    env:\n      ENV1: '{{.VAR1}}'\n    vars:\n      VAR1: 'Hello'\n```\n\nThis will not work:\n\n```yaml\ntasks:\n  task-name:\n    env:\n      ENV1: 'Hello'\n    vars:\n      VAR1:\n        sh: |\n          echo $ENV1\n```\n\n### Using environmental variables in dynamic variables\n\nSee [issue #1282][] for an explanation of how to expand environmental variables inside dynamic variables.\n- Global dynamic variables **cannot** expand global environmental variables.\n- Local dynamic variables **can** expand local or global environmental variables.\n\n[issue #1282]: https://github.com/go-task/task/issues/1282\n\n[issue #178]: https://github.com/go-task/task/issues/178\n\n[issue #454]: https://github.com/go-task/task/issues/454\n\n[included Taskfile]: https://taskfile.dev/usage/#namespace-aliases\n\n## Coding guidelines (best practices?)\n\n- For double quotes, prefer `{{ quote .MY_VARIABLE }}` over `\"{{.MY_VARIABLE}}\"` to escape double quotes.\n- Likewise with single quotes, prefer `{{ squote .MY_VARIABLE }}` over `'{{.MY_VARIABLE}}'` to escape single quotes.\n- Enclose paths in double quotes `\"{{ osClean \"C:\\Program Files\\Mozilla Firefox\\firefox.exe\" }}\"` to account for spaces and backslashes.\n- See this [SO answer][] for nesting conditionals in Go templates.\n- vars are not passed to subtasks automatically; they need to be [passed explicitly][].\n- [Boolean][sprig Default Functions]: Use empty string \"\" for false, non-empty string for true.\n- Environmental variables are case-insensitive on Windows and case-sensitive on \\*nix. The initial case is preserved on the first call but all uppercase on subsequent calls. See [issue 1229][].\n\n### Multi-line PowerShell commands\n\nIn order to use mutliline PowerShell commands from the command line, add an extra return after the code block.\nSee [Powershell fails to run multi-line commands from stdin][].\n\n- Add `-ExecutionPolicy Bypass` to bypass the execution policy for this script only.\n\n```text\npowershell -NonInteractive -NoProfile -NoLogo -InputFormat text -OutputFormat text -WindowStyle Hidden -Command - \u003c\u003c 'EOT'\n  if (-not (Test-Path -Path \"{{.BIN_DIR}}\")) {\n    New-Item -Path \"{{.BIN_DIR}}\" -ItemType Directory | Out-Null\n  }\n\nEOT\n```\n\n[SO answer]: https://stackoverflow.com/a/68361609\n\n[passed explicitly]: https://github.com/go-task/task/issues/888#issuecomment-1273264393\n\n[sprig Default Functions]: https://go-task.github.io/slim-sprig/defaults.html\n\n[issue 1229]: https://github.com/go-task/task/issues/1229\n\n[Powershell fails to run multi-line commands from stdin]: https://stackoverflow.com/questions/37417613/powershell-fails-to-run-multi-line-commands-from-stdin\n\n### Modifying existing env vars\n\nModifying _existing_ environmental variables for tasks is impossible because\nthe [system env have preference over Taskfile envs][]. The environmental variable will need to be set at the beginning\nof each `cmd` that needs the modified env var.\n\n[system env have preference over Taskfile envs]: https://github.com/go-task/task/issues/436#issuecomment-768582760\n\n### Path separators\n\n[sprig path][Sprig's path] documentation mentions that paths are separated by the `os.PathSeparator` variable and\nprocessed by the `path/filesystem` package. Unfortunately, `os.PathSeparator` is not available as a path separator in\nTask. Using a forward slash `/` on Windows and passing it through `osClean` works. If a path separator is needed,\n`FS_PATH_SEP` can be defined as a variable.\n\n```yaml\n    vars:\n      FS_PATH_SEP: '{{ if eq OS \"windows\" }}\\{{ else }}/{{ end }}'\n```\n\n[sprig path]: https://go-task.github.io/slim-sprig/paths.html\n\n### Joining paths on Windows\n\nTo join paths on Windows, joint the paths using `print` and pipe it into `osClean` and add double quotes around teh\ntemplate expression. Remember, the underlying shell is bash calling PowerShell. Piping `print` or `osClean` to `quote`\nwill double the backslashes `\\`. Run the `testing:join-path` task to see this in action.\n\n```yaml\n      - cmd: |\n          echo PowerShell osClean test: \"{{ print .BIN_PATH .FS_PATH_SEP .PATH2 .FS_PATH_SEP \"maintenanceservice.log\" | osClean }}\"\n          powershell -NonInteractive -NoProfile -NoLogo -InputFormat text -OutputFormat text -Command '\n            $file=\"{{ print .BIN_PATH .FS_PATH_SEP .PATH2 .FS_PATH_SEP \"maintenanceservice.log\" | osClean }}\"\n            Write-Output \"File: $file\"\n          '\n```\n\n## Enhancements\n\n- The [gh cli][] requires authentication for all actions. It's highly unlikely to be supported.\n- [ghrel][] is an alternative to download files from GitHub. If it didn't download to the current directory, this may be a good alternative.\n- [just][] is a command runner. Don't know if it will be useful.\n\n[gh cli]: https://github.com/cli/cli\n\n[ghrel]: https://github.com/jreisinger/ghrel\n\n[just]: https://github.com/casey/just\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniceguyit%2Ftaskfiles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fniceguyit%2Ftaskfiles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniceguyit%2Ftaskfiles/lists"}