This repository has been archived by the owner on Aug 16, 2024. It is now read-only.
forked from salesforce/dockerfile-image-update
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.ci.deploy.sh
executable file
·59 lines (50 loc) · 2.37 KB
/
.ci.deploy.sh
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
#!/usr/bin/env bash
# Validate required environment variables
declare -a vars=(JDK_VERSION encrypted_00fae8efff8c_key encrypted_00fae8efff8c_iv \
encrypted_96e73e3cb232_key encrypted_96e73e3cb232_iv CI_DEPLOY_USER CI_DEPLOY_PASSWORD \
GPG_KEY_NAME GPG_PASSPHRASE DOCKER_USERNAME DOCKER_PASSWORD NEW_PATCH_VERSION)
for var_name in "${vars[@]}"
do
if [ -z "$(eval "echo \$$var_name")" ]; then
echo "Missing environment variable $var_name"
exit 1
fi
done
set -ex
# Set up git email / name for tagging
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
# Set up Maven settings and release
mkdir -p "${HOME}/.m2"
cp .ci.settings.xml "${HOME}"/.m2/settings.xml
docker run --rm -v "${PWD}":/usr/src/build \
-v "${HOME}/.m2":/root/.m2 \
-w /usr/src/build \
-e encrypted_96e73e3cb232_key \
-e encrypted_96e73e3cb232_iv \
-e encrypted_00fae8efff8c_key \
-e encrypted_00fae8efff8c_iv \
-e CI_DEPLOY_USER \
-e CI_DEPLOY_PASSWORD \
-e GPG_KEY_NAME \
-e GPG_PASSPHRASE \
maven:3.6-jdk-"${JDK_VERSION}" \
/bin/bash -c "source .ci.prepare-ssh-gpg.sh && cd dockerfile-image-update && mvn --quiet --batch-mode deploy -P release scm:tag -Drevision=${NEW_PATCH_VERSION}"
# Get MVN_VERSION
MVN_VERSION=$(cat ./dockerfile-image-update/target/classes/version.txt)
echo "Bundling Maven version ${MVN_VERSION}"
#Package what we've released to Maven Central
docker build --tag salesforce/dockerfile-image-update \
--build-arg JDK_VERSION="${JDK_VERSION}" --build-arg MVN_VERSION="${MVN_VERSION}" .
# Push latest docker image
set +x
echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin
set -x
docker push salesforce/dockerfile-image-update
# Tag / push image locked to Maven version of the command-line module
docker tag salesforce/dockerfile-image-update salesforce/dockerfile-image-update:"${MVN_VERSION}"
docker push salesforce/dockerfile-image-update:"${MVN_VERSION}"
# Tag / push image locked to git short hash
SHORT_HASH=$(git rev-parse --short HEAD)
docker tag salesforce/dockerfile-image-update salesforce/dockerfile-image-update:"${SHORT_HASH}"
docker push salesforce/dockerfile-image-update:"${SHORT_HASH}"