Search code examples
github-pagesgithub-pages-deploy-action

Instructions for custom GitHub Pages deploy


Can someone point me to the instructions for setting up a custom deploy for GitHub pages? (My Google skills are failing me.)

I have a site that needs only one modification when I deploy it on GitHub Pages: I want to replace all occurrences of foo.com with bar.com. I know that the first two steps are

  1. Add the .nojekyll file
  2. Configure GitHub Actions to check out the repo then run a simple search/replace script on all the .html files.

At this point, do I need to do anything else? Will adding my own, custom .github directory shadow/overwrite any necessary actions for deploying the web site?


(For those who are curious: I know that I can write a simple Jekyll plug-in to do this; but, I'd rather not add the Jekyl front matter to my files. Plus, Jekyll seems like overkill for the one, simple transformation I need.)


Solution

  • Considering JamesIves/github-pages-deploy-action can be configured to push your production-ready code into any branch you'd like, an alternative would be for your action to:

    • include a steps: - name: Replace which would replace the text in what was checked out
    • deploy the current checked out (and modified) folder

    For the first point, you can use for instance a find-and-replace action, to find foo.com and replace it with bar.com.


    Note: since you are using a GitHub Action, you can specify said action as publishing source

    You can now deploy to a GitHub Pages site directly from a repository using GitHub Actions, without needing to set up a publishing source.

    Using Actions to orchestrate Pages publishing provides many more options for choosing your authoring framework (Next.js, Hugo, Gatsby, Jekyll, NuxtJS or other technologies, and the associated versions thereof) as well as giving you finer control over the publishing process, such as leveraging deployment gates.

    We have written several starter workflows for the most common frameworks but also have a “Static“ option if you want to deploy the contents of your repository with no build step.

    https://i0.wp.com/user-images.githubusercontent.com/14911070/178842638-51b834d3-6c54-423e-95fa-822f734fa98a.png?ssl=1