Build Static Site with Contentful and Github Actions

contentful, github, programming20-12-2020

Stage Setting

Static contents are managed using Contentful and able to set up a webhook from Contentful against a repository in Github so that we can rebuild the site on changes in Contentful. I need to input the access token in plain text into Contentful as a secret to give it access to the repository

How I did it?

Used the following reference to achieve the goal by using a personal access token: https://www.contentful.com/blogs/2020/06/01/running-static-site-builds-with-github-actions-and-contentful/

We don’t need to do all those, just a few steps for the “machine_user” or “Bot”

The Challenge

The token would have access to ALL private repositories (inside the organization). I would like to restrict access to a specific repository. For example, https://github.com/the-org/contentful-repository.

Solution

To achieve this, we need to do the following:

  1. Create an email address for the bot. Since we need this for step
  2. Register the newly created user in Github.
  3. Add the “Machine User” or Bot to the organization and provide repository access to only one specific repository.
  4. Generate a personal access token for the “machine_user” account.

Add The Bot as Collaborator to the Organization

After step 1 and step 2, it’s time to configure the bot. For this example we will use Contentful Bot. The picture is Gir from the animated TV series Invader Zim.

github bot account image

github bot account in dashboard

Make sure your “bot” have only one access which is the private repository.

image of the permission of bot

Generate the Personal Token for the Bot

You can achieve this by logging in as the Bot and go straight to the profile settings.

Developer Settings

image of developer settings

Personal access tokens

image of personal access token config

Click on repo

image of developer settings repository

After this step, it showed the token. Copied it and sent it to the ticket reporter. Reporter confirmed that the bot/machine_user worked as expected.

Support

Thank you for being a valued reader of my blog! Your support means the world to me and helps me continue to create valuable content for you. Here are a few ways you can show your support:

Author's photo

Herman Menor, Jr.

I'm a traveler, foodie, gamer, baller and trader viewed as a Web Developer and Software Engineer.

See other articles:

undefinedThumbnail

Solving Windows and WSL2 DNS Problem

WSL2 is a feature in Windows allowing users to run Linux directly on their Windows machines, improving performance and compatibility

wsl2, dns22-01-2024

undefinedThumbnail

Ansible Testing Practice

DevOps is already part of my tasks as an experienced Software Engineer and Web Developer. Here are some practice to test your Ansible script.

DevOps25-10-2023