{"id":20757879,"url":"https://github.com/amdmi3/github_env","last_synced_at":"2026-05-20T16:38:45.218Z","repository":{"id":139657786,"uuid":"486615589","full_name":"AMDmi3/github_env","owner":"AMDmi3","description":"Simple tool to manage $GITHUB_ENV in GitHub actions","archived":false,"fork":false,"pushed_at":"2022-04-28T16:38:41.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-18T04:44:01.818Z","etag":null,"topics":["environment-variables","github-actions","github-env"],"latest_commit_sha":null,"homepage":"","language":"Python","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/AMDmi3.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"COPYING","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":"2022-04-28T13:55:27.000Z","updated_at":"2022-04-28T14:46:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"947e590a-c23d-4cee-83a5-86770617fa80","html_url":"https://github.com/AMDmi3/github_env","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AMDmi3%2Fgithub_env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AMDmi3%2Fgithub_env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AMDmi3%2Fgithub_env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AMDmi3%2Fgithub_env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AMDmi3","download_url":"https://codeload.github.com/AMDmi3/github_env/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243067199,"owners_count":20230880,"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":["environment-variables","github-actions","github-env"],"created_at":"2024-11-17T09:46:11.010Z","updated_at":"2026-05-20T16:38:40.182Z","avatar_url":"https://github.com/AMDmi3.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CI](https://github.com/AMDmi3/github_env/actions/workflows/ci.yml/badge.svg)](https://github.com/AMDmi3/github_env/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/AMDmi3/github_env/branch/master/graph/badge.svg?token=87aZsxlja2)](https://codecov.io/gh/AMDmi3/github_env)\n[![Github commits (since latest release)](https://img.shields.io/github/commits-since/AMDmi3/github_env/latest.svg)](https://github.com/AMDmi3/github_env)\n\n# github_env\n\nWhen using GitHub actions, [environment\nvariables](https://docs.github.com/en/actions/learn-github-actions/environment-variables)\nare often used. In complex scenarios, variables are stored in\n[`$GITHUB_ENV`](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable)\nfile. However, this file does not allow straightforward appending\nvariables which is often needed. This small script simplifies this\ntask, allowing to modify environment by rewriting variables, as well\nas appending, prepending, removing values from variables, and\nundefining them. There's also support for conditional execution\nbased on expression.\n\n## Usage\n\n```shell\ngithub_env.py FOO=bar    # add or rewrite a variable \ngithub_env.py FOO+=bar   # append to a variable\ngithub_env.py FOO++=bar  # prepend to a variable\ngithub_env.py FOO-=bar   # remove value from a variable\ngithub_env.py !FOO       # undefine a variable\n\n# explicitly pass path to env file, but you don't need it\n# because it's retrieved from $GITHUB_ENV automatically\ngithub_env.py --file env\n\n# conditional execution to use with GitHub actions expressions\ngithub_env.py --if ${{ matrix.compiler == 'clang' }} CFLAGS+=-Werror\n```\n\n## Obtaining\n\nYou can install the script in your CI environment with plain `curl`.\n- It's advisable to fetch from a specific tag (and not a `master`\n  branch) to avoid possible breakages due to incompatible changes.\n- You may set a shorter name for the script.\n\n```shell\ncurl -s https://raw.githubusercontent.com/AMDmi3/github_env/0.0.1/github_env.py \u003e e; chmod 755 e\n```\n\n## Example\n\nIt's pretty common to have a logic like this which tunes environment\nbased on settings from matrix:\n\n```yaml\njobs:\n  build:\n    stragegy:\n      matrix:\n        include\n          - { cxx: g++, coverage: true }\n          - { cxx: clang++, coverage: false }\n    steps:\n      ...\n      - name: Set up environment\n        run: |\n          echo 'CXX=${{ matrix.cxx }}' \u003e\u003e $GITHUB_ENV\n          echo 'CXXFLAGS=-Wall -Wextra -pedantic' \u003e\u003e $GITHUB_ENV\n      - name: Set up environment (compiler-specific flags)\n        if: ${{ matrix.cxx == 'clang++' }}\n        run: echo \"CXXFLAGS=$CXXFLAGS -Wno-self-assign-overloaded\" \u003e\u003e $GITHUB_ENV\n      - name: Set up environment (coverage)\n        if: ${{ matrix.coverage }}\n        run: |\n          echo \"CXXFLAGS=$CXXFLAGS --coverage\" \u003e\u003e $GITHUB_ENV\n          echo \"LDFLAGS=$LDFLAGS --coverage\" \u003e\u003e $GITHUB_ENV\n```\n\nAnd here's how it's simplified with `github_env.py` script:\n\n```yaml\n      - name: Set up environment\n        run: |\n          curl -s https://raw.githubusercontent.com/AMDmi3/github_env/0.0.1/github_env.py \u003e e; chmod 755 e\n          ./e 'CXX=${{ matrix.cxx }}'\n          ./e 'CXXFLAGS=-Wall -Wextra -pedantic'\n          ./e --if ${{ matrix.cxx == 'clang++' }} 'CXXFLAGS+=-Wno-self-assign-overloaded'\n          ./e --if ${{ matrix.coverage }} 'CXXFLAGS+=--coverage' 'LDFLAGS+=--coverage'\n```\n\n## Author\n\n- [Dmitry Marakasov](https://github.com/AMDmi3) \u003camdmi3@amdmi3.ru\u003e\n\n## License\n\nMIT, see [COPYING](COPYING).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famdmi3%2Fgithub_env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famdmi3%2Fgithub_env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famdmi3%2Fgithub_env/lists"}