Skip to content

Commit

Permalink
Merge pull request #299 from cloudfoundry/create_final_release_gcs_bu…
Browse files Browse the repository at this point in the history
…cket

Add GCS configuration option for create-final-release task
  • Loading branch information
jochenehret authored Nov 24, 2023
2 parents 3e58d42 + a74b768 commit 2753581
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
33 changes: 23 additions & 10 deletions tasks/create-final-release/task
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,28 @@ if [ ! -f semantic-version/version ]; then
fi
}

setup_aws_access() {
write_aws_config_private() {
set +x
BLOBS_BUCKET_ACCESS_KEY_ID="${BLOBS_BUCKET_ACCESS_KEY_ID:?"\$BLOBS_BUCKET_ACCESS_KEY_ID not set"}"
BLOBS_BUCKET_SECRET_KEY="${BLOBS_BUCKET_SECRET_KEY:?"\$BLOBS_BUCKET_SECRET_KEY not set"}"
cat > "release-repo/config/private.yml" <<EOF
---
blobstore:
provider: s3
options:
access_key_id: ${BLOBS_BUCKET_ACCESS_KEY_ID}
secret_access_key: ${BLOBS_BUCKET_SECRET_KEY}
EOF
set -x
}

write_config_private() {
write_gcp_config_private() {
set +x
cat > "release-repo/config/private.yml" <<EOF
---
blobstore:
provider: s3
options:
access_key_id: ${BLOBS_BUCKET_ACCESS_KEY_ID}
secret_access_key: ${BLOBS_BUCKET_SECRET_KEY}
credentials_source: static
json_key: |
${BLOBS_BUCKET_GCS_JSON_KEY}
EOF
set -x
}
Expand All @@ -47,9 +53,16 @@ create_release() {
main() {
fail_fast

setup_aws_access

write_config_private
if [[ -n "${BLOBS_BUCKET_ACCESS_KEY_ID}" ]] && [[ -n "${BLOBS_BUCKET_SECRET_KEY}" ]]; then
echo "Using AWS credentials"
write_aws_config_private
elif [[ -n "${BLOBS_BUCKET_GCS_JSON_KEY}" ]]; then
echo "Using GCP credentials"
write_gcp_config_private
else
echo "Error: Either BLOBS_BUCKET_ACCESS_KEY_ID and BLOBS_BUCKET_SECRET_KEY or BLOBS_BUCKET_GCS_JSON_KEY must be set."
exit 1
fi

create_release

Expand Down
1 change: 1 addition & 0 deletions tasks/create-final-release/task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ run:
params:
BLOBS_BUCKET_ACCESS_KEY_ID:
BLOBS_BUCKET_SECRET_KEY:
BLOBS_BUCKET_GCS_JSON_KEY:

0 comments on commit 2753581

Please sign in to comment.