How to Handle Multi-line Strings and Newlines in GitHub Actions
Tadashi Shigeoka · Tue, January 3, 2023
I’ll introduce how to handle multi-line strings and newlines in GitHub Actions.
Prerequisite: Understanding the Risk of Script Injections
First, it’s assumed that you understand the GitHub Docs section on スクリプト インジェクションのリスクを理解する.
Solution: Handle Multi-line Strings and Newlines with Delimiters
You can handle multi-line strings and newlines using delimiters like EOF.
steps:
- name: Set the value in bash
id: multiline_strings
run: |
echo 'multiline_strings<> $GITHUB_ENV
echo '1' >> $GITHUB_ENV
echo '2' >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
For more details, please refer to the following pages:
- 複数行の文字列 - GitHub Actions のワークフロー コマンド - GitHub Docs
- github actions - How to fix or avoid Error: Unable to process file command 'output' successfully? - Stack Overflow
That’s all for using multi-line strings and newlines in GitHub Actions. That’s all from the Gemba.