Skip to content

Instantly share code, notes, and snippets.

@clarkritchie
Created August 22, 2023 22:06
Show Gist options
  • Save clarkritchie/d3c35a9feeec5ed62ddbb38172ee62c2 to your computer and use it in GitHub Desktop.
Save clarkritchie/d3c35a9feeec5ed62ddbb38172ee62c2 to your computer and use it in GitHub Desktop.
name: hello-world
on:
push:
branches-ignore:
- main
workflow_dispatch:
inputs:
environment:
description: 'To what environment?'
type: choice
default: 'dev'
options:
- dev
- staging
- prod
jobs:
hello-job:
name: hello-world
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment }}
steps:
- name: nested-ternary
run: |
SECRET=${{ github.event.inputs.environment == 'dev' && secrets.DEV_SECRET || github.event.inputs.environment == 'staging' && secrets.STAGING_SECRET || secrets.PROD_SECRET }}
if [[ ${SECRET} == "xxx" ]]; then
echo "use the secret for dev"
elif [[ ${SECRET} == "yyy" ]]; then
echo "use the secret for staging"
else
echo "use the secret for prod"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment