GitHub Actions for AWS, Azure and GCP
By Brian
I’m abandoning the multi-cloud blog hosting model that I was using in favor of AWS Amplify to simplify TLS configuration. But I thought I should document the old approach a little further in case I ever go back to it.
The build pipeline for my blog fails every once in a while. For example, there was an issue with the Azure CLI earlier this month. Each time that happens it takes me a few minutes to remember how the pipeline works. Therefore, I am documenting it quickly in this post.
Build
As I described in this post, my blog was hosted on AWS, Azure and GCP. There is a GitHub Action that runs for each cloud provider . Each script starts with the same three steps Checkout, Install, and Build.
|
|
I’m using peaceiris/actions-hugo@v2 to build the hugo content. This was chosen at random. I have, on occasion, needed to specify a specific version of Hugo to avoid a bug. For example.
|
|
Also, note the Hugo command line has a few options. The environment variable is needed to control the Robots Meta Tag and the environment flag sets cloud provider in the page footer.
|
|
The remainder of the GitHub Actions script is cloud provider specific. In each case, I am using the CLI to sync the latest static site to the cloud.
AWS
AWS uses a two step process. First I log in as an IAM user and then run s3 sync
.
|
|
I have an IAM user defined with permissions scoped to a single S3 bucket. The access and secret key for that user are stored as secrets in GitHub.
GCP
Google Cloud is nearly identical to AWS. There are distinct Login and Deploy steps.
|
|
I have service account defined in GCP. The GCP_SA_KEY secret is the entire Key in JSON format.
Azure
Azure is a little different. Rather than creating a user, I am using the access keys for the storage account. Therefore, there is no distinct login step.
|
|
The secrets are simply the name of the storage account and one of the two access keys. These are available on storage account page.