Best strategy to deploy static site to s3 on githu

2019-03-14 08:44发布

I'd like to automate deploying our site to AWS S3. I've written a node script to automate building and uploading the site, but I'd like to have the script automatically run whenever the master branch of our repo is updated on github.

I looked into AWS CodeDeploy, but it looks like that's for specifically deploying to EC2. I've also looked at AWS Lambda, but there doesn't seem to be a clear way to pull a copy of the repo using git so I can run the script.

Any services (preferably tied to AWS) that I can use?

8条回答
Fickle 薄情
2楼-- · 2019-03-14 09:45

If you are using TravisCI, the deployment is pretty straight forward. The only part you will need to add to your .travis.yml is :

deploy:                         
  provider: s3                         
  access_key_id: "YOUR AWS ACCESS KEY"
  secret_access_key:
    secure: "w/DlbHt1+IAMENCRYPTED"
  bucket: "YOUR BUCKET"

My blog post explains all the details for the AWS side (user setup, IAM and S3 bucket configurations) as well as the github and travisCI side.

查看更多
手持菜刀,她持情操
3楼-- · 2019-03-14 09:47

Perhaps overpowered for your simple use case, but you could create a very simple CodePipeline to push your github repository to S3.

查看更多
登录 后发表回答