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
This action can output the following environment names:
stage
uat
production
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.
See action.yml for more info about the action.
- uses: gbh-tech/[email protected]
id: env
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 }}"