-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploy the web site to the habitat account
* Set up needed environment variables in .travis.yml * Move fastly keys to Ruby section of .travis.yml * Add middlman-s3_sync * Add binstub for middlman * Add terraform variables and resources for www * Add support/ci/deploy_website.sh, which runs on master Signed-off-by: Nathan L Smith <[email protected]> Pull request: #794 Approved by: reset
- Loading branch information
1 parent
db3f0a6
commit 222f40a
Showing
8 changed files
with
168 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
git log HEAD~1..HEAD | grep -q '!!! Temporary Commit !!!' | ||
is_tmp_commit=$? | ||
|
||
# If we are not on a pull request, on the "auto" branch (which homu uses when | ||
# auto-merging master), and not on a temporary commit, then run the publish | ||
# script. | ||
if [ "${TRAVIS_PULL_REQUEST}" = "false" ] && | ||
[ "${TRAVIS_BRANCH}" = "auto" ] && | ||
[[ $is_tmp_commit = 1 ]]; then | ||
set -eux | ||
cd www && ./bin/middleman s3_sync | ||
curl -H "Fastly-Key: ${FASTLY_API_KEY}" -X POST "https://api.fastly.com/service/${FASTLY_SERVICE_KEY}/purge_all" | ||
else echo "Not on master; skipping website deploy"; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
resource "aws_iam_user" "www" { | ||
name = "${var.www_user}" | ||
} | ||
|
||
resource "aws_iam_user_policy" "www" { | ||
name = "${var.www_user}" | ||
user = "${aws_iam_user.www.name}" | ||
|
||
policy = <<EOF | ||
{ | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Action": [ | ||
"s3:DeleteObject", | ||
"s3:GetObject", | ||
"s3:ListBucket", | ||
"s3:PutObject" | ||
], | ||
"Resource": "arn:aws:s3:::${aws_s3_bucket.www.bucket}/*" | ||
}, | ||
{ | ||
"Action": "s3:ListAllMyBuckets", | ||
"Effect": "Allow", | ||
"Resource": "arn:aws:s3:::*" | ||
} | ||
] | ||
} | ||
EOF | ||
} | ||
|
||
resource "aws_s3_bucket" "www" { | ||
bucket = "${var.www_bucket_name}" | ||
acl = "public-read" | ||
|
||
website { | ||
index_document = "index.html" | ||
error_document = "404/index.html" | ||
} | ||
|
||
policy = <<EOF | ||
{ | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Principal": { | ||
"AWS": [ | ||
"*" | ||
] | ||
}, | ||
"Resource": "arn:aws:s3:::${var.www_bucket_name}/*", | ||
"Action": "s3:GetObject" | ||
}, | ||
{ | ||
"Effect": "Allow", | ||
"Principal": { | ||
"AWS": "arn:aws:iam::${var.aws_account_id}:user/${aws_iam_user.www.name}" | ||
}, | ||
"Resource": "arn:aws:s3:::${var.www_bucket_name}", | ||
"Action": "s3:*" | ||
} | ||
] | ||
} | ||
EOF | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
# | ||
# This file was generated by Bundler. | ||
# | ||
# The application 'middleman' is installed as part of a gem, and | ||
# this file is here to facilitate running it. | ||
# | ||
|
||
require "pathname" | ||
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", | ||
Pathname.new(__FILE__).realpath) | ||
|
||
require "rubygems" | ||
require "bundler/setup" | ||
|
||
load Gem.bin_path("middleman-cli", "middleman") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters