Similarly, I would expect the following to work:
on: deployment
jobs:
deploy:
runs-on: ubuntu-20.04
environment: ${{ github.event.deployment.environment }}
env:
ENVIRONMENT: ${{ github.event.deployment.environment }}
steps:
- name: Deploy to ${{ github.event.deployment.environment }}
env:
FOO: ${{ secrets.FOO }}
run: echo "FOO in $ENVIRONMENT is ${FOO:0:1}+${FOO:1}"
Given that an environment can have up to 100 secrets that get mapped in env
(and potentially more from the org and repo), it’s not sustainable to maintain duplicate workflows that change only the static environment
string.
Additionally, because there is not an environment
filter available for the deployment
event trigger, it seems like the above on: deployment
workflow would need to be rewritten to act as a switch
statement that triggers one of the duplicated static environment workflows based on the value of github.event.deployment.environment
. Something like this:
on: deployment
jobs:
deploy:
runs-on: ubuntu-20.04
env:
ENVIRONMENT: ${{ github.event.deployment.environment }}
steps:
- run: |
if [ $ENVIRONMENT = "production" ]; then
# trigger deploy-production workflow
elif [ $ENVIRONMENT = "staging" ]; then
# trigger deploy-staging workflow
elif [ $ENVIRONMENT = "develop" ]; then
# trigger deploy-develop workflow
else
# not a supported environment
fi
Am I thinking about environments wrong? How is this feature intended to be used with only static strings?