Skip to content

[github actions] shell parameter expansion: replace character ( ${parameter/%pattern/string} ) #45488

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

You must be logged in to vote

There's no way to dynamically set an environment variable for all jobs. But you could use outputs to transfer the values between jobs (mind that this requires a needs relationship between the jobs):

jobs:
  set-vars:
    runs-on: ubuntu-latest
    outputs:
      version: ${{ steps.gen_version.outputs.VERSION }}
    steps:
      - name: set values
        id: gen_version
        run: |
          echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
      - name: Use the value
        # this sets environment variables for this step
        env:
          VERSION: ${{ steps.gen_version.outputs.VERSION }}
        run: |
          echo "${VERSION}"

  other-job:
    needs: [set-vars]
    r…

Replies: 10 comments 6 replies

Comment options

You must be logged in to vote
1 reply
@markjreed
Comment options

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
1 reply
@Aryayantox73
Comment options

Answer selected by kwladyka
Comment options

You must be logged in to vote
4 replies
@jge162
Comment options

@airtower-luna
Comment options

@jge162
Comment options

@airtower-luna
Comment options

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Actions Build, test, and automate your deployment pipeline with world-class CI/CD Question
5 participants