-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
buildspec.yml.disabled
100 lines (96 loc) · 4.83 KB
/
buildspec.yml.disabled
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
version: 0.2
phases:
install:
commands:
- export CI=true
- export CODEBUILD=true
- export CODEBUILD_ACCOUNT_ID=$(aws sts get-caller-identity --query 'Account' --output text)
- export CODEBUILD_GIT_BRANCH="$(git symbolic-ref HEAD --short 2>/dev/null)"
- if [ "$CODEBUILD_GIT_BRANCH" = "" ] ; then
CODEBUILD_GIT_BRANCH="$(git branch -a --contains HEAD | sed -n 2p | awk '{ printf $1 }')";
export CODEBUILD_GIT_BRANCH=${CODEBUILD_GIT_BRANCH#remotes/origin/};
fi
- export CODEBUILD_GIT_CLEAN_BRANCH="$(echo $CODEBUILD_GIT_BRANCH | tr '/' '.')"
- export CODEBUILD_GIT_ESCAPED_BRANCH="$(echo $CODEBUILD_GIT_CLEAN_BRANCH | sed -e 's/[]\/$*.^[]/\\\\&/g')"
- export CODEBUILD_GIT_MESSAGE="$(git log -1 --pretty=%B)"
- export CODEBUILD_GIT_AUTHOR="$(git log -1 --pretty=%an)"
- export CODEBUILD_GIT_AUTHOR_EMAIL="$(git log -1 --pretty=%ae)"
- export CODEBUILD_GIT_COMMIT="$(git log -1 --pretty=%H)"
- export CODEBUILD_GIT_SHORT_COMMIT=$(echo $CODEBUILD_SOURCE_VERSION | cut -c 1-7)
- export CODEBUILD_GIT_TAG="$(git describe --tags --exact-match 2>/dev/null)"
- export CODEBUILD_GIT_MOST_RECENT_TAG="$(git describe --tags --abbrev=0)"
- export CODEBUILD_PULL_REQUEST=false
- case "${CODEBUILD_SOURCE_VERSION}" in
*pr/* ) echo "pull request";
export PULL_REQUEST=$(echo ${CODEBUILD_SOURCE_VERSION} | tr / -);
export CODEBUILD_PULL_REQUEST="${PULL_REQUEST}";
export CODEBUILD_GIT_CLEAN_BRANCH=${CODEBUILD_PULL_REQUEST};
;;
* ) echo "not pull request";;
esac
- if [ "${CODEBUILD_SOURCE_VERSION}" = *"pr/"* ]; then
echo "pull request";
export PULL_REQUEST=$(echo ${CODEBUILD_SOURCE_VERSION} | tr / -);
export CODEBUILD_PULL_REQUEST="${CODEBUILD_GIT_BRANCH}-${PULL_REQUEST}";
export CODEBUILD_GIT_CLEAN_BRANCH=${CODEBUILD_GIT_CLEAN_BRANCH};
else
echo "not pull request";
fi
#- if [ "${CODEBUILD_GIT_BRANCH#pr-}" != "$CODEBUILD_GIT_BRANCH" ] ; then
# export CODEBUILD_PULL_REQUEST=${CODEBUILD_GIT_BRANCH#pr-};
# fi
- export CODEBUILD_PROJECT=${CODEBUILD_BUILD_ID%:$CODEBUILD_LOG_PATH}
- export CODEBUILD_BUILD_URL=https://$AWS_DEFAULT_REGION.console.aws.amazon.com/codebuild/home?region=$AWS_DEFAULT_REGION#/builds/$CODEBUILD_BUILD_ID/view/new
- export IMAGE_TAG=$CODEBUILD_GIT_SHORT_COMMIT
- export ACCOUNT=$CODEBUILD_ACCOUNT_ID
- echo "==> AWS CodeBuild Extra Environment Variables:"
- echo "==> CI = $CI"
- echo "==> CODEBUILD = $CODEBUILD"
- echo "==> CODEBUILD_ACCOUNT_ID = $CODEBUILD_ACCOUNT_ID"
- echo "==> CODEBUILD_GIT_AUTHOR = $CODEBUILD_GIT_AUTHOR"
- echo "==> CODEBUILD_GIT_AUTHOR_EMAIL = $CODEBUILD_GIT_AUTHOR_EMAIL"
- echo "==> CODEBUILD_GIT_BRANCH = $CODEBUILD_GIT_BRANCH"
- echo "==> CODEBUILD_GIT_CLEAN_BRANCH = $CODEBUILD_GIT_CLEAN_BRANCH"
- echo "==> CODEBUILD_GIT_ESCAPED_BRANCH = $CODEBUILD_GIT_ESCAPED_BRANCH"
- echo "==> CODEBUILD_GIT_COMMIT = $CODEBUILD_GIT_COMMIT"
- echo "==> CODEBUILD_GIT_SHORT_COMMIT = $CODEBUILD_GIT_SHORT_COMMIT"
- echo "==> CODEBUILD_GIT_MESSAGE = $CODEBUILD_GIT_MESSAGE"
- echo "==> CODEBUILD_GIT_TAG = $CODEBUILD_GIT_TAG"
- echo "==> CODEBUILD_GIT_MOST_RECENT_TAG = $CODEBUILD_GIT_MOST_RECENT_TAG"
- echo "==> CODEBUILD_PROJECT = $CODEBUILD_PROJECT"
- echo "==> CODEBUILD_PULL_REQUEST = $CODEBUILD_PULL_REQUEST"
- if [ "$CODEBUILD_GIT_CLEAN_BRANCH" = "master" ] ; then
export DEPLOY_DIR='/';
else
export DEPLOY_DIR=${CODEBUILD_GIT_CLEAN_BRANCH};
fi
- echo '***** This is the current env:'
- printenv
- ls -lah
- pwd
build:
commands:
- npm install
- npm run theme
- echo "<p class="build-number">${IMAGE_TAG}</p>" >> layouts/partials/menu-footer.html
- cat layouts/partials/menu-footer.html
- if [ "${CODEBUILD_GIT_CLEAN_BRANCH}" != "master" ] ; then
sed -i "s@branch =.*@branch = \"$CODEBUILD_GIT_CLEAN_BRANCH\"@" config.toml;
fi
- cat config.toml
- npm run build
- npm run deploytemplates
- curl https://api.github.com/rate_limit
- if [ "$CODEBUILD_GIT_CLEAN_BRANCH" = "master" ] ; then
npm run test;
else
echo skipping this test docker run -v $PWD/public/:/public 18fgsa/html-proofer /public --empty-alt-ignore --allow-hash-href --url-swap "/$CODEBUILD_GIT_CLEAN_BRANCH:" --external-only;
fi
- curl https://api.github.com/rate_limit
post_build:
commands:
- if [ "${CODEBUILD_BUILD_SUCCEEDING}" != "1" ] ; then
echo "the build failed -- not continuing with post build";
exit 99;
fi
- ./codebuild-deploy.sh