Skip to content

Instantly share code, notes, and snippets.

@mloza
Created November 27, 2019 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mloza/76bb9347c765de25b7f04e5c247c9eec to your computer and use it in GitHub Desktop.
Save mloza/76bb9347c765de25b7f04e5c247c9eec to your computer and use it in GitHub Desktop.
#!/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