Created
November 27, 2019 12:41
-
-
Save mloza/76bb9347c765de25b7f04e5c247c9eec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -z "${CODEBUILD_RESOLVED_SOURCE_VERSION:-}" ]; then | |
{ | |
echo "Error: CODEBUILD_RESOLVED_SOURCE_VERSION is not set" | |
} >&2 | |
exit 1 | |
else | |
echo "Resolved hash: ${CODEBUILD_RESOLVED_SOURCE_VERSION}" | |
fi | |
echo "Creating tmp dirs" | |
mkdir tmp | |
cd tmp | |
echo "Clonning repository" | |
git clone https://$GITHUB_API_TOKEN:x-oauth-basic@github.com/username/repository-name ./ | |
echo "Resetting to version from build" | |
git reset "$CODEBUILD_RESOLVED_SOURCE_VERSION" | |
echo "Moving git dir to build directory" | |
cd ../ | |
mv tmp/.git ./ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment