{"id":16725234,"url":"https://github.com/unfor19/configmap-action","last_synced_at":"2025-08-02T09:35:34.535Z","repository":{"id":122056852,"uuid":"455525692","full_name":"unfor19/configmap-action","owner":"unfor19","description":"Exports configmap.json as a job-output according to a given key, such as `GIT_BRANCH` or `DEPLOYMENT_ENVIRONMENT`, which is later consumed by other jobs with \"needs\".","archived":false,"fork":false,"pushed_at":"2022-11-06T11:29:02.000Z","size":55,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"development","last_synced_at":"2025-01-22T05:17:40.761Z","etag":null,"topics":["actions","configmap","configuration","deployment","github","matrix"],"latest_commit_sha":null,"homepage":"https://meirg.co.il","language":"Shell","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/unfor19.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-04T11:39:43.000Z","updated_at":"2022-08-30T04:20:04.000Z","dependencies_parsed_at":"2023-06-09T05:30:33.090Z","dependency_job_id":null,"html_url":"https://github.com/unfor19/configmap-action","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unfor19%2Fconfigmap-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unfor19%2Fconfigmap-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unfor19%2Fconfigmap-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unfor19%2Fconfigmap-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unfor19","download_url":"https://codeload.github.com/unfor19/configmap-action/tar.gz/refs/heads/development","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243746234,"owners_count":20341203,"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","configmap","configuration","deployment","github","matrix"],"created_at":"2024-10-12T22:48:24.076Z","updated_at":"2025-03-15T15:14:36.074Z","avatar_url":"https://github.com/unfor19.png","language":"Shell","readme":"# configmap-action\n\n[![testing](https://github.com/unfor19/configmap-action/workflows/testing/badge.svg)](https://github.com/unfor19/configmap-action/actions?query=workflow%3Atesting)\n[![test-action](https://github.com/unfor19/configmap-action-test/workflows/test-action/badge.svg)](https://github.com/unfor19/configmap-action-test/actions?query=workflow%3Atest-action)\n\nExports [configmap.json](./configmap.json) as a [job-output]([output](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idoutputs)) according to a given key, such as `GIT_BRANCH` or `DEPLOYMENT_ENVIRONMENT`, which is later consumed by other jobs with \"[needs](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idneeds)\".\n\nFor GitHub Enterprise customers, the same idea is implemented by [Using environments for deployment\n](https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment). Bear in mind that:\n\n\u003e Environments, environment protection rules, and environment secrets are available in public repositories for all products. For access to environments in private repositories, you must use GitHub Enterprise. For more information, see \"GitHub's products.\"\n\nThis action is an alternative implemenation of GitHub Environments, for using environment specific configurations according to a given key; such as `GIT_BRANCH`, see [Usage](#Usage) section.\n\nTested in [unfor19/configmap-action-test](https://github.com/unfor19/configmap-action-test/actions?query=workflow%3Atest-action)\n\n## Requirements\n\nGitHub's Linux [ubuntu-20.04](https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md) runners include the below requirements.\n\n1. [Bash v4.4+](https://www.gnu.org/software/bash/)\n2. [jq v1.6+](https://stedolan.github.io/jq/)\n\n\u003e **NOTE**: If you're using [Self-Hosted runners](https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners), make sure you have the above requirements installed on the runner.\n\n\u003e **TODO**: Create a new repo that builds a new version of the Docker image [summerwind/actions-runner:latest](https://github.com/actions-runner-controller/actions-runner-controller#software-installed-in-the-runner-image). That will ease the process of implementing this action when using [actions-runner-controller](https://github.com/actions-runner-controller/actions-runner-controller#software-installed-in-the-runner-image).\n\n\n## Usage\n\n1. Create a [configmap.json](./configmap.json) in your git repository\n2. Add the following job to the top of an existing workflow; I'm using [github.ref_name](https://docs.github.com/en/actions/learn-github-actions/contexts#:~:text=github.ref_name) to dynamically select the relevant configmap per environment.\n   ```yaml\n   prepare:\n     runs-on: ubuntu-20.04\n     name: Prepare ${{ github.event.inputs.src_repository }}\n     steps:\n       - uses: actions/checkout@v2\n       # Assuming `configmap.json` exists in the git repo\n       - name: Set Configmap\n         env:\n           CONFIGMAP_FILE_PATH: configmap.json\n         id: set-configmap\n         run: |\n           echo \"configmap=$(jq -c . ${{ env.CONFIGMAP_FILE_PATH }})\" \u003e\u003e $GITHUB_OUTPUT\n       - name: Export Configmap\n         uses: unfor19/configmap-action@development\n         with:\n           configmap_map: ${{ steps.set-configmap.outputs.configmap }}\n           configmap_key: ${{ github.ref_name }} # The branch or tag name that triggered the workflow run\n           configmap_default_key_name: \"default\" # The default configuration to fetch when configmap_key is not found\n           configmap_skip_env: \"false\" # By default, all outputs are exported as env var in $GITHUB_ENV Set to true if you wish to disable this behavior\n         id: export-configmap\n      ### Required outputs - feel free to add more outputs\n      ### -----------------------------------------------------\n      outputs:\n        CONFIGMAP: ${{ steps.export-configmap.outputs.CONFIGMAP_MAP }}\n        CONFIGMAP_SELECTED_KEY: ${{ steps.export-configmap.outputs.CONFIGMAP_SELECTED_KEY }}\n      ### -----------------------------------------------------\n   ```\n3. Consume `prepare`'s output `CONFIGMAP` as a [matrix](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix) in existing jobs, such as `build`\n   ```yaml\n   build:\n     runs-on: ubuntu-20.04\n     name: Build ${{ matrix.configmap.NODE_VERSION }}\n     ### Add the following block to each job\n     ### -----------------------------------------------------\n     needs:\n       - prepare\n     strategy:\n       matrix:\n         configmap: ${{ fromJSON(needs.prepare.outputs.CONFIGMAP) }}\n     ### -----------------------------------------------------\n     steps:\n       - uses: actions/checkout@v2\n       # Inject relevant variables per step\n       - name: Get env vars\n         env:\n           NODE_ENV: ${{ matrix.configmap.NODE_ENV }}\n           NODE_VERSION: ${{ matrix.configmap.NODE_VERSION }}\n         run: |\n           echo \"$NODE_ENV\"\n           echo \"$NODE_VERSION\"\n   ```\n\n### Consuming GitHub Actions Secrets\n\nSecrets **names** are exposed to all steps in a job, though values of secrets can be selectively injected to relevant steps, see example below.\n\n1. Assuming `configmap.json` contains the following secrets names\n   ```json\n   {\n     \"production\": [\n       {\n         ...\n         \"AWS_ACCESS_KEY_ID_NAME\": \"AWS_ACCESS_KEY_ID_PRODUCTION\",\n         \"AWS_SECRET_ACCESS_KEY_NAME\": \"AWS_SECRET_ACCESS_KEY_PRODUCTION\"\n       }\n     ],\n     \"development\": [\n       {\n         ...\n         \"AWS_ACCESS_KEY_ID_NAME\": \"AWS_ACCESS_KEY_ID_DEVELOPMENT\",\n         \"AWS_SECRET_ACCESS_KEY_NAME\": \"AWS_SECRET_ACCESS_KEY_DEVELOPMENT\"\n       }\n     ]\n   }\n   ```\n2. Create secrets per environment (development, staging, production, etc.) in GitHub Actions\n   - AWS_ACCESS_KEY_ID_DEVELOPMENT\n   - AWS_SECRET_ACCESS_KEY_DEVELOPMENT\n   - AWS_ACCESS_KEY_ID_PRODUCTION\n   - AWS_SECRET_ACCESS_KEY_PRODUCTION\n3. Consume secrets as environment variables with `secrets[matrix.configmap.SECRET_NAME]`.\n   ```yaml\n     deploy:\n       runs-on: ubuntu-20.04\n       name: Deploy to ${{ needs.prepare.outputs.CONFIGMAP_SELECTED_KEY }}\n       needs:\n         - prepare\n         - build\n       strategy:\n         matrix:\n           configmap: ${{ fromJSON(needs.prepare.outputs.CONFIGMAP) }}\n       env:\n         DEPLOYMENT_ENVIRONMENT: ${{ needs.prepare.outputs.CONFIGMAP_SELECTED_KEY }}\n       ### -----------------------------------------------------\n       steps:\n         - uses: actions/checkout@v2\n         # Inject relevant variables per step\n         - name: Get env vars\n           env:\n             AWS_ACCESS_KEY_ID: ${{ secrets[matrix.configmap.AWS_ACCESS_KEY_ID_NAME] }}\n             AWS_SECRET_ACCESS_KEY: ${{ secrets[matrix.configmap.AWS_SECRET_ACCESS_KEY_NAME] }}\n           run: |\n             echo \"Deploying to $DEPLOYMENT_ENVIRONMENT\"\n             echo \"AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID\"\n             echo \"AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY\"\n   ```\n\n\n## Authors\n\nCreated and maintained by [Meir Gabay](https://github.com/unfor19)\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](https://github.com/unfor19/configmap-action/blob/master/LICENSE) file for details\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funfor19%2Fconfigmap-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funfor19%2Fconfigmap-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funfor19%2Fconfigmap-action/lists"}