Deploy your hexo site from your build server directly to S3!
hexo alreday offers a mechanism to deploy your site to various targets. But this mechanism involves generating the files from hexo before deploying them. If you want to follow a staging process, you want to generate your files once and deploy them to various servers. A typical process could look like this:
hexo generate
Install hexo-to-s3:
npm install hexo-to-s3 --save-dev
You have multiple options to execute a deployment.
Add this entry to your package.json:
{
"scripts": {
"deploy": "hexo-to-s3"
}
}
Execute this npm command to deploy:
npm run-script deploy --bucket YOUR_BUCKET_NAME
Execute this npm command to deploy:
node node_modules/hexo-to-s3/bin/hexo-to-s3.js --bucket YOUR_BUCKET_NAME
Mandatory parameter that defines the upload target
Optional, defines the region that is used for the upload. If this parameter is not set, hexo-to-s3 tries to read the environment variable AWS_DEFAULT_REGION.
hexo-to-s3 uses the Amazon AWS SDK underneath. You can use the usual means to load credentials. More information can be found here.