Skip to content

Commit 79cf715

Browse files
committed
Call git-crypt unlock in CI
- Replace calls to `configure_apply` with calls to `.buildkite/git-crypt/unlock.sh` - Commit the prebuilt binary to use on our EC2 images on CI(1), alongside the Dockerfile that was used to create it(2) (1) In the future we'll probably pre-provision our custom Android AMI with it instead of shipping it inside each repo (2) In theory we could use `docker run --rm -v …` to run `git-crypt` from within the Docker container, instead of extracting the binary from the Docker image and committing that binary. But for this to work, that requires to not only map the repo's dir as volume in the container, but also map the repo mirror dir used during `git clone --reference` / listed in `.git/objects/info/alternates`; so that can get tricky in CI that uses that git mirrors mechanism. Besides, the binary is pretty small (200KB) and being able to run it directly without Docker is not only simpler but avoids pulling the docker image in the CI agent before we can run it.
1 parent aa05f02 commit 79cf715

File tree

12 files changed

+70
-10
lines changed

12 files changed

+70
-10
lines changed

.buildkite/commands/diff-merged-manifest.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ echo "--- :rubygems: Setting up Gems"
1515
install_gems
1616

1717
echo "--- :closed_lock_with_key: Installing Secrets"
18-
bundle exec fastlane run configure_apply
18+
.buildkite/git-crypt/unlock.sh
1919

2020
echo "--- 💾 Diff Merged Manifest (Module: WooCommerce, Build Variant: ${BUILD_VARIANT})"
2121
comment_with_manifest_diff "WooCommerce" ${BUILD_VARIANT}

.buildkite/commands/gradle-cache-build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ echo "--- :rubygems: Setting up Gems"
1414
install_gems
1515

1616
echo "--- :closed_lock_with_key: Installing Secrets"
17-
bundle exec fastlane run configure_apply
17+
.buildkite/git-crypt/unlock.sh
1818

1919
echo "--- :hammer_and_wrench: Building"
2020
./gradlew assembleWasabiDebug

.buildkite/commands/prototype-build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ echo "--- :rubygems: Setting up Gems"
1313
install_gems
1414

1515
echo "--- :closed_lock_with_key: Installing Secrets"
16-
bundle exec fastlane run configure_apply
16+
.buildkite/git-crypt/unlock.sh
1717

1818
echo "--- :hammer_and_wrench: Building ${APP_TO_BUILD}"
1919
bundle exec fastlane build_and_upload_prototype_build app:"${APP_TO_BUILD}"

.buildkite/commands/release-build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ echo "--- :rubygems: Setting up Gems"
66
install_gems
77

88
echo "--- :closed_lock_with_key: Installing Secrets"
9-
bundle exec fastlane run configure_apply
9+
.buildkite/git-crypt/unlock.sh
1010

1111
echo "--- :hammer_and_wrench: Building ${APP_TO_BUILD}"
1212
bundle exec fastlane build_and_upload_google_play app:"${APP_TO_BUILD}"

.buildkite/commands/run-instrumented-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ echo "--- :rubygems: Setting up Gems"
1212
install_gems
1313

1414
echo "--- :closed_lock_with_key: Installing Secrets"
15-
bundle exec fastlane run configure_apply
15+
.buildkite/git-crypt/unlock.sh
1616

1717
echo "--- 🧪 Testing"
1818
set +e

.buildkite/commands/run-unit-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ echo "--- :rubygems: Setting up Gems"
1212
install_gems
1313

1414
echo "--- :closed_lock_with_key: Installing Secrets"
15-
bundle exec fastlane run configure_apply
15+
.buildkite/git-crypt/unlock.sh
1616

1717
echo "+++ 🧪 Testing"
1818
set +e

.buildkite/git-crypt/Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
### Builder Layer
2+
3+
FROM amazonlinux:latest AS builder
4+
5+
ENV VERSION=0.8.0
6+
7+
RUN dnf install -y \
8+
make \
9+
gcc-c++ \
10+
openssl-devel \
11+
tar \
12+
gzip
13+
14+
RUN curl -L https://github.com/AGWA/git-crypt/archive/$VERSION.tar.gz | tar -zxv
15+
16+
RUN cd git-crypt-$VERSION \
17+
&& make \
18+
&& make install PREFIX=/usr/local
19+
20+
### Final Layer
21+
22+
FROM amazonlinux:latest
23+
COPY --from=builder /usr/local/bin/git-crypt /usr/local/bin/git-crypt
24+
25+
WORKDIR /repo
26+
VOLUME /repo
27+
ENTRYPOINT ["/usr/local/bin/git-crypt"]
28+
29+
# To extract the binary and commit it into the repository, follow these steps:
30+
#
31+
# $ docker build --platform linux/amd64 -t git-crypt .
32+
# $ CONTAINER_ID=$(docker create git-crypt)
33+
# $ docker cp $CONTAINER_ID:/usr/local/bin/git-crypt ./git-crypt.linux-x86_64
34+
# $ docker rm $CONTAINER_ID
205 KB
Binary file not shown.

.buildkite/git-crypt/unlock.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
if [ -z "$GIT_CRYPT_ENCRYPTION_KEY" ]; then
4+
echo "GIT_CRYPT_ENCRYPTION_KEY is not set"
5+
exit 1
6+
fi
7+
8+
set -euo pipefail
9+
10+
echo "Checking for git-crypt..."
11+
if command -v git-crypt >/dev/null 2>&1; then
12+
echo " - Using system git-crypt"
13+
gitcrypt_path="git-crypt"
14+
elif [ "$(uname -s)" == "Linux" ] && [ "$(uname -m)" == "x86_64" ]; then
15+
echo " - Using pre-compiled x86_64 git-crypt"
16+
gitcrypt_path=".buildkite/git-crypt/git-crypt.linux-x86_64"
17+
else
18+
echo "Unable to find git-crypt binary (architecture: $(uname -s) $(uname -m))"
19+
exit 1
20+
fi
21+
22+
echo "🔓 Decrypting repository..."
23+
"${gitcrypt_path}" unlock <(echo "${GIT_CRYPT_ENCRYPTION_KEY}" | base64 -d)
24+
echo "✅ git-crypt unlocked"

.buildkite/release-pipelines/download-release-translations.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ steps:
1313
echo '--- :ruby: Setup Ruby Tools'
1414
install_gems
1515
16+
echo '--- :closed_lock_with_key: Installing Secrets'
17+
.buildkite/git-crypt/unlock.sh
18+
1619
echo '--- :globe_with_meridians: Download Release Translations'
1720
bundle exec fastlane download_release_translations skip_confirm:true include_wear_app:"${INCLUDE_WEAR_APP:-false}"
1821
agents:

0 commit comments

Comments
 (0)