Skip to content

Commit 2aa3e34

Browse files
authored
Merge pull request #2 from carlpett/docker-hooks
Use docker build hooks to inject correct plugin version
2 parents aa40a2c + 0ac69f6 commit 2aa3e34

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

.circleci/config.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,16 @@ jobs:
1818
- run: make build
1919
- run:
2020
name: Download github-release tool
21-
command: curl -sL 'https://github.com/aktau/github-release/releases/download/v0.6.2/linux-amd64-github-release.tar.bz2' | tar xjf - --strip-components 3 -C /go/bin
21+
command: |
22+
curl -sL 'https://github.com/aktau/github-release/releases/download/v0.6.2/linux-amd64-github-release.tar.bz2' | \
23+
tar xjf - --strip-components 3 -C /go/bin
2224
- run: github-release upload --user carlpett --repo terraform-sops --tag $CIRCLE_TAG --name terraform-provider-sops_$CIRCLE_TAG-linux-amd64 --file terraform-provider-sops
25+
- run:
26+
name: Trigger Docker Hub automated build
27+
command: |
28+
curl -X POST -H "Content-Type: application/json" \
29+
--data "{\"source_type\": \"Tag\", \"source_name\": \"$CIRCLE_TAG\"}" \
30+
https://registry.hub.docker.com/u/carlpett/terraform-sops/trigger/$DOCKER_HUB_TRIGGER_TOKEN/
2331
- store_artifacts:
2432
path: terraform-provider-sops
2533

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
FROM hashicorp/terraform:light
2-
ENV SOPS_PLUGIN_VERSION=v0.0.1
2+
ARG SOPS_PLUGIN_VERSION
3+
ENV SOPS_PLUGIN_VERSION=${SOPS_PLUGIN_VERSION}
34
RUN curl -sLo /bin/terraform-provider-sops_${SOPS_PLUGIN_VERSION} https://github.com/carlpett/terraform-sops/releases/download/${SOPS_PLUGIN_VERSION}/terraform-provider-sops_${SOPS_PLUGIN_VERSION}-linux-amd64 && \
45
chmod +x /bin/terraform-provider-sops_${SOPS_PLUGIN_VERSION}

docker/hooks/build

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
set -eufo pipefail
3+
if ! echo ${DOCKER_TAG} | grep -qE '^v[0-9\.]+'; then
4+
# If the tag is not a version, use the version of the latest tag
5+
git fetch --tags --unshallow >/dev/null
6+
export DOCKER_TAG=$(git describe --tags --abbrev=0 --match='v*')
7+
echo "Using plugin version ${DOCKER_TAG}"
8+
fi
9+
docker build --build-arg "SOPS_PLUGIN_VERSION=${DOCKER_TAG}" -t "${IMAGE_NAME}" .

0 commit comments

Comments
 (0)