Skip to content

Set environment variable based on git branch #25301

Answered by Notalifeform
ralph asked this question in Actions
Discussion options

You must be logged in to vote

Solution above works, but is being deprecated:

The GitHub Blog

GitHub Actions: Deprecating set-env and add-path commands - GitHub Changelog

GitHub Actions: Deprecating set-env and add-path commands

so it looks like this

steps:
    - name: Set env to staging
      if: endsWith(github.ref, '/develop')
      run: |
        echo "ENVIRONMENT=staging" >> $GITHUB_ENV
    - name: Set env to production
      if: endsWith(github.ref, '/master')
      run: |
       echo "ENVIRONMENT=production" >> $GITHUB_ENV

Replies: 8 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

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

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
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
Labels
None yet
6 participants