I'm currently trying to setup a deployment process using AWS CodePipeline. My source is Github, which is a repo that contains git submodules. In order to clone the submodules, I'm using the buildspec.yml file below in the build phase:
version: 0.2
env:
variables:
git_url: "url to github repo"
parameter-store:
ssh_key: ssh_key
ssh_pub: ssh_key.pub
config_file: config_file
phases:
pre_build:
commands:
- mkdir -p ~/.ssh
- echo "$ssh_key" > ~/.ssh/ssh_key
- echo "$ssh_pub" > ~/.ssh/ssh_key.pub
- echo "$config_file" > ~/.ss+-h/config
- chmod 600 ~/.ssh/ssh_key
- chmod 600 ~/.ssh/ssh_key.pub
- eval "$(ssh-agent -s)"
- git init
- git remote add origin "$git_url"
- git fetch origin
- git branch
- git checkout -f "$CODEBUILD_RESOLVED_SOURCE_VERSION"
- git submodule init
- git submodule update --recursive
build:
commands:
- echo Build started on `date`
post_build:
commands:
- echo Build completed on `date`
artifacts:
base-directory: outputDirectory
files:
- '**/*'
- .ebextensions/**/*
The CodeBuild logs' confirms that the git submodules are successfully being cloned into the build:
[Container] 2021/12/02 19:02:11 Running command git submodule update --recursive
Cloning into '/codebuild/output/src/src/Modules/Module1'...
Cloning into '/codebuild/output/src/src/Modules/Module2'...
Cloning into '/codebuild/output/src/src/Modules/Module3'...
Submodule path 'Modules/Module1': checked out 'latest commit'
Submodule path 'Modules/Module2': checked out 'latest commit'
Submodule path 'Modules/Module3': checked out 'latest commit'
Yet when I check my S3 bucket for the build's zip file, there are no files inside the submodules' folders. For example, Module1 is there, but it's an empty folder.
Where are the git submodule files going? The only thing that happens after the build is a deploy to the Elastic Beanstalk instance.