masamicooks.com 🍱🍜🍲
Welcome, this is the source code for masamicooks, the online cooking blog!
The content for this site comes from Contentful, and is not stored within the repository.
- Configure
.env
file for Contentful API.
CONTENTFUL_SPACE_ID=
CONTENTFUL_DELIVERY_TOKEN=
CONTENTFUL_PREVIEW_TOKEN=
npm install
npm start
This repository is configured to deploy to a production environment whenever there is a push into the main branch. The repository therefore relies upon several environment variables to be set, including:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_BUCKET_NAME
AWS_BUCKET_REGION
CLOUDFRONT_DISTRIBUTION_ID
TF_API_TOKEN
CONTENTFUL_ACCESS_TOKEN
CONTENTFUL_SPACE_ID
Variables 1 and 2 are immediately accessible via the AWS console and allow Terraform to connect and configure our infrastructure.
After an initial deploy of the infrastructure from our local machine, we will have to supply variables 3 through 5 into the environment.
Item 6 is available via the Terraform Cloud console.
Items 7 and 8 are available via the Contentful console. These are the keys that allow Github Actions to pull down the content we need to build our site.
The contentful API triggers a deploy of our site whenever the user publishes a new piece of content. This is done via a webhook. The webhook is listened for inside of our deployment Github Action.
This action is basically triggered via a POST request to the https://api.github.com/repos/harrisoncramer/masamicooks/dispatches
endpoint, carrying our authorization token from Github and the payload of:
{ "event_type": "webhook" }
This will get detected by our Github Action, which will run the deploy. We only send this POST in Contentful when a piece of content is published or unpublished!