2

I want to use the GITHUB_SHA with a variable, like this:

name: build
on: ["push"]

env:
  PACKAGE: package-$GITHUB_SHA

But, when I use, yaml does not expand the variable and I got the string. How I can do it?

2 Answers 2

3

According to https://help.github.com/en/actions/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#github-context:

As part of an expression, you may access context information using one of two syntaxes.

Index syntax: github['sha']
Property dereference syntax: github.sha

In this case:

name: build
on: ["push"]

env:
  PACKAGE: package-${{ github.sha }}
Sign up to request clarification or add additional context in comments.

Comments

0

Try the following:

name: build
on: ["push"]

env:
  PACKAGE: package-${{ github.sha }}

2 Comments

Almost there. The correct answer is VM_NAME: ubuntu-env-${{ github.sha }} Update your answer, so I can give u kudos
This won't work because GITHUB_SHA is not defined in the context but rather in the environment

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.