Skip to content

Instantly share code, notes, and snippets.

@headforthecloud
Last active March 17, 2023 09:09
Show Gist options
  • Select an option

  • Save headforthecloud/18494a43442ee3edc24b912bcde78441 to your computer and use it in GitHub Desktop.

Select an option

Save headforthecloud/18494a43442ee3edc24b912bcde78441 to your computer and use it in GitHub Desktop.
This is an example of an AWS CodeCatalyst (https://codecatalyst.aws) workflow definition. See https://headforthe.cloud/article/deploying-a-hugo-blog-with-codecatalyst/ for more info
Name: BuildHugoBlog
SchemaVersion: "1.0"
# Optional - Set automatic triggers.
Triggers:
- Type: Push
# Required - Define action configurations.
Actions:
InstallandRunHugo:
Identifier: aws/build@v1
Inputs:
Sources:
- WorkflowSource
Outputs:
AutoDiscoverReports:
Enabled: false
Artifacts:
- Name: blogOutput
Files:
- public/**/*
Configuration:
Steps:
- Run: wget
https://github.com/gohugoio/hugo/releases/download/v0.111.2/hugo_0.111.2_linux-amd64.tar.gz
- Run: tar xzvf hugo_0.111.2_linux-amd64.tar.gz
- Run: git submodule init
- Run: git submodule update
- Run: ./hugo
Compute:
Type: EC2
PublishToS3:
Identifier: aws/s3-publish@v1
Environment:
Connections:
- Role: CodeCatalystPreviewDevelopmentAdministrator-5thw79
Name: headforthecloud
Name: headforthecloud
Inputs:
Artifacts:
- blogOutput
Compute:
Type: EC2
Configuration:
DestinationBucketName: headforthe.cloud
SourcePath: public
DependsOn:
- InstallandRunHugo
InvalidateCloudFront:
Identifier: aws/build@v1
Outputs:
AutoDiscoverReports:
Enabled: false
Compute:
Type: EC2
DependsOn:
- PublishToS3
Environment:
Connections:
- Role: CodeCatalystPreviewDevelopmentAdministrator-5thw79
Name: headforthecloud
Name: headforthecloud
Inputs:
Sources:
- WorkflowSource
Configuration:
Steps:
- Run: dist=$(aws cloudfront list-distributions --query
"DistributionList.Items[*].{id:Id,alias:Aliases.Items[0]}[?alias=='headforthe.cloud'].id"
--output text)
- Run: if [ -z "$dist" ]; then echo "Cannot find cloudfront distribution for
domain";false; fi
- Run: aws cloudfront create-invalidation --distribution-id $dist --paths '/*'
BuildAlgoliaIndex:
Identifier: aws/build@v1
Inputs:
Sources:
- WorkflowSource
Artifacts:
- blogOutput
Outputs:
AutoDiscoverReports:
Enabled: false
ReportNamePrefix: rpt
Configuration:
Steps:
- Run: cd algolia
- Run: npm install
- Run: app_id=$(grep algolia_appId ../config.toml | cut -d\" -f2)
- Run: index_name=$(grep algolia_indexName ../config.toml | cut -d\" -f2)
- Run: npm run data-upload -- -f $CATALYST_SOURCE_DIR_blogOutput/public/index.json -a $app_id -k ${Secrets.AlgoliaAPIKey} -n $index_name >output.log
Compute:
Type: EC2
DependsOn:
- InstallandRunHugo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment