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:
- Create an email address for the bot. Since we need this for step
- Register the newly created user in Github.
- Add the “Machine User” or Bot to the organization and provide repository access to only one specific repository.
- 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.
Make sure your “bot” have only one access which is the private repository.
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
Personal access tokens
Click on repo
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:
- Share the Love: If you enjoy the articles, consider sharing them with your friends, family and social media followers. Sharing the content helps to reach a wider audience and grow a community that simply shares solving problems.
- Feedback is Appreciated: I value your feedback! Let me know what you think about the content, what topics you’d like to see more of and any suggestions you have for improving my blog. Your input helps me tailor the content to better serve you.
- Buy a Coffee: If you’d like to support financially, consider buying me a coffee. Your donation goes a long way in helping to cover the costs associated with running and maintaining the blog. Even a small contribution can make a big difference!