0

I'm new to github actions.

Below is my workflow:

name: Example

on: [push, workflow_dispatch]

env:
  APPNAME: 'myapp1'
  APPURL: "https://mybank/$APPNAME/widgets/hello.json" 

jobs:
  test:
    runs-on: windows-latest

    steps:
      - name: Print variables
        run: |
          echo "APPURL is: ${{ env.APPURL }}"

Output:

Run echo "APPURL is: https://mybank/$APPNAME/widgets/hello.json"
APPURL is: https://mybank//widgets/hello.json

I understand that env. cannot be used under at workflow level.

Is it possible to have variable interpolation APPNAME at workflow level i.e for APPURL?

Ashar
  • 2,942
  • 10
  • 58
  • 122

1 Answers1

0

This is due to the windows-latest runner using powershell by default to run command lines.

In that case, informing the shell: bash will work.

steps:
  - name: Print variables
    run: |
      echo "APPURL is: ${{ env.APPURL }}"
    shell: bash

# Will print: APPURL is: https://mybank/myapp1/widgets/hello.json

Note that using the ubuntu-latest or macos-latest runners will work as well without informing the shell, as they use bash as default.

I've made an example here using this workflow implementation with another example for concatenation that can be useful depending on what you want to achieve.

GuiFalourd
  • 15,523
  • 8
  • 44
  • 71