Skip to content

Commit

Permalink
Add Travis job for uploading zipfile to S3 (pulumi#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
lindydonna committed Mar 29, 2018
1 parent 88c79b4 commit 5fed47c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.pulumi
Pulumi.*.yaml
node_modules/
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
if: branch = master
sudo: true # give us 7.5GB and >2 bursted cores.
before_install:
# Install the AWS CLI, which is required by upload-examples.sh
- pip install --upgrade --user awscli
script:
- ./upload-examples.sh
notifications:
webhooks: https://ufci1w66n3.execute-api.us-west-2.amazonaws.com/stage/travis
29 changes: 29 additions & 0 deletions upload-examples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
# publish-examples.sh downloads a GitHub zipfile of examples repo and writes to
# s3:https://rel.pulumi.com/releases/examples/pulumi-examples.zip.
set -o nounset -o errexit -o pipefail

ROOT=$(dirname $0)
EXAMPLES_FILENAME="pulumi.examples.zip"
EXAMPLES_PATH="${ROOT}/${EXAMPLES_FILENAME}"

echo -e "Downloading ${EXAMPLES_PATH} to publish to S3"

# Download the zipfile for the examples repo at master
curl -H "Authorization: token ${GITHUB_TOKEN}" \
-L "https://github.com/pulumi/examples/archive/master.zip" > ${EXAMPLES_PATH}

# Assume the UploadPulumiReleases role first
CREDS_JSON=$(aws sts assume-role \
--role-arn "arn:aws:iam::058607598222:role/UploadPulumiReleases" \
--role-session-name "upload-plugin-pulumi-resource-aws" \
--external-id "upload-pulumi-release")

# Use the credentials we just assumed
export AWS_ACCESS_KEY_ID=$(echo ${CREDS_JSON} | jq ".Credentials.AccessKeyId" --raw-output)
export AWS_SECRET_ACCESS_KEY=$(echo ${CREDS_JSON} | jq ".Credentials.SecretAccessKey" --raw-output)
export AWS_SECURITY_TOKEN=$(echo ${CREDS_JSON} | jq ".Credentials.SessionToken" --raw-output)

aws s3 cp --only-show-errors "${EXAMPLES_PATH}" "s3:https://rel.pulumi.com/examples/${EXAMPLES_FILENAME}"

rm "${EXAMPLES_PATH}"

0 comments on commit 5fed47c

Please sign in to comment.