Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gbh-tech/set-environment-action
Outputs an environment variable by the key 'ENVIRONMENT' based on the triggering GitHub event. and git ref name.
https://github.com/gbh-tech/set-environment-action
action environment github set utility
Last synced: about 3 hours ago
JSON representation
Outputs an environment variable by the key 'ENVIRONMENT' based on the triggering GitHub event. and git ref name.
- Host: GitHub
- URL: https://github.com/gbh-tech/set-environment-action
- Owner: gbh-tech
- License: mit
- Created: 2024-03-06T20:49:54.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-05-24T20:55:10.000Z (6 months ago)
- Last Synced: 2024-10-18T05:35:45.996Z (21 days ago)
- Topics: action, environment, github, set, utility
- Language: JavaScript
- Homepage:
- Size: 72.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT
Awesome Lists containing this project
README
# Set Environment Action
## Content
- [Overview](#overview)
- [Environments](#environments)
- [Environment mapping](#environment-mapping)
- [Usage](#usage)
- [Examples](#examples)## Overview
This GitHub Action facilitates setting the environment name based on the
triggering workflow and git ref.> ⚠️ This action is tailored for our specific needs and development workflow,
> at this moment, you cannot change the triggering events or the environment
> tag. Only use if you can adapt it on your workflow!The action exposes the environment name value in two different contexts:
- Outputs
- [env context]## Environments
This action can output the following environment names:
- `stage`
- `uat`
- `production`## Environment mapping
The environment name mapping is as follows:
- Push event on a branch with name `main` -> Outputs environment **stage**.
- Tag push matching `v[0-9].[0-9].[0-9]-uat.[0-9]` -> Outputs **uat**.
- Tag matching `v[0-9].[0-9].[0-9]` -> Outputs **production**.The Action uses `github.ref_name` to determine the branch or tag name.
## Usage
See [action.yml](action.yml) for more info about the action.
```yaml
- uses: gbh-tech/[email protected]
id: env
```### Examples
```yaml
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gbh-tech/[email protected]
id: env# Using outputs
- name: Show the selected environment name using output
env:
ENVIRONMENT: ${{ steps.env.outputs.environment }}
run: echo "Environment is ${ENVIRONMENT}"# Using env. context
- name: Show the selected environment name using env context
run: echo "Environment is ${{ env.ENVIRONMENT }}"
```[env context]: https://docs.github.com/en/actions/learn-github-actions/contexts#example-contents-of-the-env-context