발단
최근 Github Action 을 활용하여 호출된 코드의 결과물을 release 주기적으로 업로드하고자 시도하였고 이 과정을 정리합니다.
문서
Workflow commands for GitHub Actions - GitHub Docs
Actions can communicate with the runner machine to set environment variables, output values used by other actions, add debug messages to the output logs, and other tasks. Most workflow commands use the echo command in a specific format, while others are in
docs.github.com
위 내용을 해석해보자면..
여러 줄 문자열 사용을 위해 문서에 명시된 문법구문을 따라야 한다고 되어있습니다.
* 주의
사용하려는 구분자가 값과 함께 줄에 작성되지 않아야 합니다. 만약 구분자가 멋대로라면 이 형식을 사용하면 안됩니다. 구분자를 파일에 직접 작성해주세요.
문서 내용 따라 작성시...
위 문서에서 예제도 존재하기에 그대로 따라해보았으나, EOF 를 인지하지 못한다는 오류가 발생하였고 EOF 가 정해진 delimiter 가 아니라는 생각을 하게 되었습니다.
문서에서 임의의 delimiter 에 대한 언급을 하고 있기에 제가 작성한 multiline strings 중 어떠한 delimiter 를 원하는지 이해하지 못하였고 환경변수 방식말고 다른 방식 찾아야 했고 아래 해결방법을 찾게 되었습니다.
해결방법
How to send multi line string in json in GitHub actions?
I am working on GitHub actions, and I have a case where I need to send a multiline string as json. I am getting some unexpected token error. This is my test.md and workflow: -----------------------...
stackoverflow.com
해결방법 링크에서는 Github Action 에서 지원하고 있는 변수 저장방식중 하나인 echo "::set-output name={{variable}}::..." (deprecated 되어 지원이 종료될 예정이라는 경고 문구가 나오니 한줄이면 최신 방식을 사용하세요...)을 사용하였고 저도 위 방식으로 multiline strings 를 사용할 수 있었습니다.
예제
- name: Set output
id: set-output
run: |
RESULT_VAR=$(cat result.txt)
RESULT_VAR="${RESULT_VAR//'%'/'%25'}"
RESULT_VAR="${RESULT_VAR//$'\n'/'%0A'}"
RESULT_VAR="${RESULT_VAR//$'\r'/'%0D'}"
echo "::set-output name=result::$RESULT_VAR"
...
- name: Create release
...
body: ${{steps.set-output.outputs.result}}
...
'Git > GitHub' 카테고리의 다른 글
[Github] github packages maven 방식으로 업로드(feat. intellij, 예제) (2) | 2023.08.24 |
---|