{"id":15791245,"url":"https://github.com/levonet/action-config-levels","last_synced_at":"2025-03-31T18:48:42.237Z","repository":{"id":48308454,"uuid":"376131528","full_name":"levonet/action-config-levels","owner":"levonet","description":null,"archived":false,"fork":false,"pushed_at":"2021-08-02T11:12:33.000Z","size":109,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-11T23:04:13.051Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/levonet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-11T20:05:31.000Z","updated_at":"2021-08-02T11:12:36.000Z","dependencies_parsed_at":"2022-08-27T08:12:05.186Z","dependency_job_id":null,"html_url":"https://github.com/levonet/action-config-levels","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/levonet%2Faction-config-levels","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/levonet%2Faction-config-levels/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/levonet%2Faction-config-levels/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/levonet%2Faction-config-levels/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/levonet","download_url":"https://codeload.github.com/levonet/action-config-levels/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246523890,"owners_count":20791443,"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":[],"created_at":"2024-10-04T23:00:31.678Z","updated_at":"2025-03-31T18:48:42.227Z","avatar_url":"https://github.com/levonet.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GitHub Action: Config Levels\n\nThis action is designed to create a configuration consisting of different levels of configuration files.\n\nDuring the merging of configuration files, objects that are at higher levels are overridden by objects that are at lower levels.\nIn the same way, objects and lists can be supplemented with each lower level of configuration.\nThe type of merging is determined by the parameters of the action.\n\nFor example, we have the following file structure in our project:\n\n```\nproject/\n  ├── .github/\n  │     ...\n  ├── group1/\n  │     ├── common.yml\n  │     ├── dev.yml\n  │     └── prod.yml\n  ├── group2/\n  │     ├── common.yml\n  │     ├── dev.yml\n  │     └── prod.yml\n  ├── common.yml\n  ├── dev.yml\n  └── prod.yml\n```\n\nWhereat the level of the folder \"project\" the general configuration is defined.\nThe `groupX` folders define a specific configuration for each group.\n\nDue to the imaginary environment variables `env.GROUP` and `env.ENV` we can get different configurations as a result of merging the contents of files.\n\n```yml\n- uses: blablacar/action-config-levels@master\n  id: config\n  with:\n    patterns: |\n      - common.yml\n      - ${{ env.ENV }}.yml\n      - ${{ env.GROUP }}/common.yml\n      - ${{ env.GROUP }}/${{ env.ENV }}.yml\n\n- run: echo '${{ steps.config.outputs.result }}'\n```\n\nConfiguration files have more weight, which is lower in the list.\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003cth\u003ecommon.yml\u003c/th\u003e\u003cth\u003edev.yml\u003c/th\u003e\u003cth\u003egroup1/common.yml\u003c/th\u003e\u003cth\u003egroup1/dev.yml\u003c/th\u003e\u003cth\u003eResult\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd valign=\"top\"\u003e\n\u003cpre\u003e\n---\nproject: hello\n\u003c/pre\u003e\n    \u003c/td\u003e\u003ctd valign=\"top\"\u003e\n\u003cpre\u003e\n---\nenvironment: dev\nlogging: INFO\n\u003c/pre\u003e\n    \u003c/td\u003e\u003ctd valign=\"top\"\u003e\n\u003cpre\u003e\n---\nlogging: DEBUG\n\u003c/pre\u003e\n    \u003c/td\u003e\u003ctd valign=\"top\"\u003e\n\u003cpre\u003e\n---\nproject: World\nhosts:\n- boo\n- foo\n\u003c/pre\u003e\n    \u003c/td\u003e\u003ctd valign=\"top\"\u003e\n\u003cpre\u003e\n{\n  \"project\": \"World\",\n  \"environment\": \"dev\",\n  \"logging\": \"DEBUG\",\n  \"hosts\": [\"boo\", \"foo\"]\n}\n\u003c/pre\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n## Inputs\n\n### `patterns`\n\n**Required** A list of path patterns to possible configuration files.\nThis field contains a string with a list in YAML format.\n\nThe file path may contain special patterns, such as `*` and `**`.\nFor more on patterns that can be used in the `patterns` parameter, see [Glob Primer](https://github.com/isaacs/node-glob#glob-primer).\n\n### `merge_object`\n\nWay to merge objects [deep, overwrite, off].\n- `deep` — merge objects deeply\n- `overwrite` — overwrite objects that are at the root\n- `off` — use the lowest level configuration file\n\nDefault: `deep`.\n\n### `merge_array`\n\nWay to merge arrays [concatenating, overwrite].\nAlso affects the type of array merge when merging objects.\n\nDefault: `concatenating`.\n\n### `merge_plain`\n\nWay to merge plain text [concatenating, overwrite].\n\nDefault: `concatenating`.\n\n### `output_properties`\n\nOutput each property of the object as JSON.\n\nDefault: `false`.\n\n### `loop`\n\nIf `loop` is defined, then the action is repeated as many times as the number of rows in the variable's content.\nAll found mentions of `{{ item }}` in the pattern are replaced with a row from the `loop` variable.\nThe iterative execution of the action returns the object as JSON, where the key contains a row,\nand the value is the result of the execution of the action according to the pattern.\nAlso it has output for each row as a serialized key with value in JSON if `output_properties` is enabled.\n\nExample:\n\n```yml\n- uses: blablacar/action-config-levels@master\n  id: config\n  with:\n    patterns: |\n      - {{ item }}/common.yml\n      - {{ item }}/${{ env.ENV }}.yml\n    loop: |\n      dir1\n      dir2/subdir\n\n- run: echo '${{ steps.config.outputs.result }}'\n\n- run: echo '${{ steps.config.outputs.dir1 }}'\n\n- run: echo '${{ steps.config.outputs.dir2_subdir }}'\n```\n\n### `loop_items_format`\n\nThe format in which the list is passed to the loop\n- `text` — each row is an item of a list\n- `json` — list in JSON format\n- `yaml` — list in YAML format\n\nDefault: `text`.\n\n### `loop_items_key`\n\nObject path to the value that acts as the key.\nHelps set the key by which the result will be available if the item contains an object.\nOtherwise, the index is used as the key.\n\n## Outputs\n\n###  `result`\n\nMerged configuration in JSON or plain text format.\nThe format is determined automatically based on file suffixes.\n`.yml`, `.yaml`, and `.json` files are converted to objects.\n\n### `\u003cobject property\u003e`\n\nReturns each property of an object in a separate output.\nProperties are returned when the `output_properties` input parameter is set to `true`.\n\n# License\n\nThe scripts and documentation in this project are released under the [MIT License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flevonet%2Faction-config-levels","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flevonet%2Faction-config-levels","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flevonet%2Faction-config-levels/lists"}