Publishing to Netlify from a private, organization-owned repository.
Published Aug 19, 2022
Netlify recently announced that they’re limiting the building of private, organization-owned GitHub repositories to their Pro plan. Repositories for the free plan must now be either public or under a personal GitHub account.
I have a few private repositories that are hosted in a team on GitHub for collaboration purposes, but which don’t produce any income. Luckily there is a rather easy workaround: building using GitHub Actions, and then publishing to Netlify afterwards.
Cleaning up on Netlify
First thing we’ll need to do is disconnect the project from the GitHub repository on Netlify. This will leave Netlify happy, as they no longer have to spend build minutes on the project, and let us stay on the free plan.
Navigate to the project you want to change on netlify and go to Site settings > Build & deploy > Continuous Deployment
. Here you’ll find a “Manage repository” dropdown, from which you can unlink the project:
This should be enough for Netlify to be happy. While you’re here, you might as well find the information we’ll need for publishing later: the site ID, and an access token.
Still within the project, head to Site settings > General > Site details
and copy down the site ID. Then head to User settings > Applications
and create a new personal access token. Make sure to copy down the token value as well. We’ll be using both of these values when we set up the GitHub Action.
Setting up the GitHub Action
The rest of the work will happen in your GitHub repo. Head over to Settings > Secrets > Actions
, and create a new secret containing the access token you’ve just copied from Netlify. We’ll be using this secret for sending the data to Netlify once we’ve built the site.
Finally all we have left to do is add the actual GitHub Action! Create a new file in .github/workflows
in your repository (e.g. .github/workflows/release.yml
), and paste an action configuration like the following:
And that’s it! You should now have GitHub Actions set up to build your site and publish the result to Netlify - even if your repository wouldn’t normally be supported by your Netlify plan.