Skip to content

Use different input parameter based on a condition #26557

Answered by airtower-luna
dingo-d asked this question in Actions
Discussion options

You must be logged in to vote

I see two issues here:

  1. The conditionals in your current_stage step are mixing Bash and GitHub Actions syntax, and the result of that is probably not what you want (both are always true, so you always get the production path because it’s checked first). You should use Actions syntax (the ${{ ... }} part) only to substitute the github.ref and Bash for the rest:
        run: |
          if [ ${{ github.ref }} = "refs/heads/main" ]; then
            echo "::set-output name=STAGE::production"
            echo "::set-output name=SSH_KEY::${{ secrets.PRODUCTION_KEY }}"
          elif [ ${{ github.ref }} = "refs/heads/staging" ]; then
            echo "::set-output name=STAGE::staging"
        …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants