[Github Action] github context

개발者·2022년 1월 4일
2

GitHub Action

목록 보기
4/6

github context 는 workflow의 실행과 트리거된 이벤트의 정보를 포함한다. enviroment 변수에 있는 대부분의 깃허브 context 데이터를 읽을 수 있다.


💡 모든 깃허브 context를 사용할 때, `github.token`과 같은 민감한 정보를 갖고 있을 수 있는 것을 명심하자. 깃허브는 그런 정보들이 콘솔에 노출될 때 마스킹(***) 하지만, 해당 context를 노출하거나 프린트 할 때 주의해야 한다.
💡 workflow나 actions를 생성할 때, 신뢰할 수 없는 입력을 처리할 수 있는지 고려해야 한다. 외부의 악의적인 공격이 발생할 수 있기에 특정 context는 신뢰할 수 없는 입력을 처리해야 한다.
Property nameType
(string or object)
Description
githubobject어느 job이나 step 에서도 사용 가능한 최고 레벨의 context.
github.actionstring현재 실행중인 action의 이름. 깃허브는 특수문자를 지우거나 __run 을 현재 스크립트가
동작중인 step으로 사용한다. 만약 같은 액션을 같은 job에서 수행하면,
이름에는 언더스코어(_)가 포함된 횟수의 suffix가 포함될 것이다.
예를 들어, 처음은 __run 이고, 두번째는 __run_2 일 것이다.
유사하게 actions/checkout 의 두번째 이름은 actionscheckout2 일 것이다.
github.action_pathstringaction이 위치하고 있는 path 이다.
이 path를 action과 같은 repo안으로 쉽게 접근하기 위해 사용할 수 있다.
이러한 특징은 복합 action에서만 지원된다.
github.actorstringworkflow를 실행시킨 유저.
github.base_refstringbase_ref 거나 workflow가 수행중인 PR의 target branch.
이 특성은 workflow가 pull_request 나 pull_request_target 에 의해 트리거되어 동작할 때만 가능하다.
github.eventobjectfull event webhook payload. 해당 context에서 사용하는 이벤트의 각각의 특성에 접근 가능하다.
github.event_namestringworkflow 실행을 트리거한 이벤트의 이름.
github.event_pathstringrunner의 full event webhook payload 의 path.
github.head_refstringhead_ref 나 workflow가 수행중인 PR 의 source branch.
이 특성은 workflow가 pull_request 나 pull_request_target 에 의해 트리거되어 동작할 때만 가능하다.
github.jobstring현재 job의 job_id.
github.refstringworkflow 수행을 트리거한 branch나 tag의 ref.
branch를 위한 포맷은 refs/heads/<branch_name>,
tag는 refs/tags/<tag_name> 이다.
github.ref_namestringworkflow의 수행을 트리거한 branch나 tag의 이름.
github.ref_protectedstringworkflow의 수행을 트리거한 ref 를 위한 branch protections이 설정되어 있으면 true .
github.ref_typestringworkflow의 수행을 트리거한 ref의 type. 가능한 값은 branchtag.
github.repositorystringowner와 repo의 이름. 예를 들면, Codertocat/Hello-World .
github.repository_ownerstringrepo의 owner의 이름. 예를 들어, Codertocat .
github.run_attemptstringrepo에서 각 workflow 수행 시도의 유니크 값이다.
1 부터 시작해서 재수행될 때마다 증가한다.
github.run_idstringrepo에서 각 수행의 고유한 값이다. workflow를 재수행 해도 값은 변하지 않는다.
github.run_numberstringrepo에서 각 workflow 수행의 고유한 값이다. workflow의 첫 수행에 1로 시작해서 각 새로운 run 마다 증가한다.
재수행에서는 해당 값이 변경되지 않는다.
github.server_urlstringGithub Server의 URL을 반환한다. ex) https://github.com.
github.shastringworkflow의 수행을 트리거한 커밋 SHA.
github.tokenstringrepo에 설치된 Github App 대신의 인증 토큰.
이것은 기능적으로 GITHUB_TOKEN 과 동일하다.
github.workflowstringworkflow의 이름. 만약 workflow 파일의 이름을 지정하지 않는다면 repo에 있는 workflow 파일의 full path 값이다.
github.workspacestringcheckout action 을 사용할 때, step 을 위한 default working 디렉토리와 repo의 default location.

reference

profile
solrasido

0개의 댓글