Use multi-line values in GitHub Actions
The wider context is that we use GitHub Discussions to plan meeting agendas. The meeting discussions always need to include the same explanatory text, a link to the video call (currently not included as it’s about to change), and information about the Code of Conduct. The action makes this very quick for any of the project members to do in preparation for the next meeting.
The steps look something like this:
- I put the Markdown to use as the content of the discussion into a file
.github/templates/agenda.md
. It’s quite nice to have it as its own Markdown file as it’s easier to edit and update by itself. -
In order to access this file, the GitHub action needs a checkout action.
-
The next
step
reads the file and puts it into an environment variable. It took me a while to find how to do this, but here’s what I ended up with:- name: Get agenda text from template id: get-agenda run: | echo 'AGENDA<<EOF' >> $GITHUB_ENV cat .github/templates/agenda.md >> $GITHUB_ENV echo 'EOF' >> $GITHUB_ENV
- Then I used the value in the next
step
with the notation${{ env.AGENDA }}
.
GitHub Discussions isn’t supported in the v3 API as far as I can see, so I used the v4 GraphQL API instead. You can see the full action in the repository if you’re interested.
Posts like this are great, cause I would have spend so much time figuring out how to do this — now it’s bookmarked. Thanks.