Home > Back-end >  How to use Github Actions to generate a checksum and set env variable?
How to use Github Actions to generate a checksum and set env variable?

Time:01-20

Would like to generate a checksum via Github Actions and set to env variable CHECKSUM like so:

     - name: Create checksum
       run: echo CHECKSUM=$(shasum -a 1 foo.zip | awk '{ print $1 }') >> $CHECKSUM

but it returns an error:

/home/runner/work/_temp/b6f2fd2a-359b-4052-a439-4f5b0a629a85.sh: line 1: $CHECKSUM: ambiguous redirect

CodePudding user response:

Setting environment variables works differently: you append to a file whose name is stored in the $GITHUB_ENV variable, i.e., something like

run: |
  echo CHECKSUM="$(shasum foo.zip | awk '{ print $1 }')" >> "$GITHUB_ENV"
  •  Tags:  
  • Related