DevOps

Github Action 에서 submodule 까지 checkout 하기

KAispread 2023. 6. 28. 14:59
728x90
반응형

🔹 github action - submodule 옵션

일반 git clone이나 git pull 명령어로 슈퍼 프로젝트의 하위에 있는 서브 모듈 코드까지 가져올 수 없다. git clone에는 --recurse-submodule 옵션을 붙여주어야 하고, git submodule update --remote 를 통해 서브 모듈의 변경 사항을 가져와야한다.

github action에서도 마찬가지이다. github repository를 checkout 하기 위해서 checkout action을 사용하는데, submodule 에 대한 속성 값을 설정해주어야 서브 모듈까지 checkout 할 수 있다.

checkout 에 대한 공식 문서를 보면 다음과 같이 설명하고 있다.

- uses: actions/checkout@v3
  with:
    # Whether to checkout submodules: `true` to checkout submodules or `recursive` to
    # recursively checkout submodules.
    #
    # When the `ssh-key` input is not provided, SSH URLs beginning with
    # `git@github.com:` are converted to HTTPS.
    #
    # Default: false
    submodules: ''

https://github.com/marketplace/actions/checkout

 

Checkout - GitHub Marketplace

Checkout a Git repository at a particular version

github.com

 

결과적으로 다음과 같이 submodule 옵션을 true로 설정해주기만 하면 된다.

- uses: actions/checkout@v3
        with:
          submodules: true

 

 

🔹 submodule 이 private 일 경우

- uses: actions/checkout@v3
        with:
          token: ${{ secrets.ACCESS_TOKEN }}
          submodules: true

submodule 이 private 일 경우, 해당 저장소에 대한 접근 권한이 필요하다. 따라서 token 옵션에 본인의 personal access key를 넣어, github action runner가 서브 모듈을 checkout 할 수 있도록 해야한다.

github action을 사용하는 저장소 -> settings -> secrets and variables 에 ACCESS_TOKEN 이름으로 본인의 personal access key를 넣어주면 된다.

 

 

728x90
반응형