Issue
I am playing around with the idea of using Elixir in GitHub actions workflows, because I think it would make for an excellent CI language (better than bash at least).
GitHub Actions does not have a straight-forward way to do this (like it does with nodejs).
There is an action for installing Elixir though, so I have access to elixir
and iex
within the bash runtime of my workflow.
I'm thinking I could do something like this:
# Install Elixir
- uses: erlef/setup-beam@v1
with:
elixir-version: ${{ env.ELIXIR_VERSION }}
# Run Elixir code via bash
- run: |
elixir -e "IO.puts(1336 + 1)"
This works. But is it possible to pass a multiline string, containing my script, to elixir -e
?
The following does not work:
elixir -e <<-EOT
IO.puts(68+1)
EOT
I guess I could just create a file, but for small scripts I feel like it would be cleaner to just pipe in a heredoc.
Solution
Since you don't want to use the stdin of elixir, using a here-doc is pointless. You could however provide a multiline string:
elixir -e 'first line
second line
third line
'
Answered By - user1934428 Answer Checked By - Mary Flores (WPSolving Volunteer)