BYOJS / byojs.github.io

landing page
https://byojs.dev
MIT License
5 stars 2 forks source link

Investigate using custom actions for gh-pages publish of this org #3

Open getify opened 1 month ago

getify commented 1 month ago

I'm aware of how to use custom github actions for publishing to gh-pages (via a .github/workflows like I'm doing here).

However, I'm not sure if that same approach can work here, where the repository itself is used as the main org gh-pages deployment.

What I would like to be able to do is dynamically generate the list of projects -- currently hard coded in the index.html from the list of pinned projects of this BYOJS org. I was imagining a custom github action that uses the github API to query the repository, get the list of pinned projects, then push in the generated HTML to the index.html. Perhaps even could use a simple templating engine, like Mustache.

But the first question to figure out is, can this special repo -- again, used as the org gh-pages deploy -- itself override its deployment with a custom gh-pages deployment? I haven't been able to find any documentation on whether this special case has such support, all the docs I found were either about doing custom actions for a normal repo, OR doing this special magic deployment of a repo for the org, not both together.

QuantumAbraham commented 1 month ago

What I would like to be able to do is dynamically generate the list of projects -- currently hard coded in the index.html from the list of pinned projects of this BYOJS org. I was imagining a custom github action that uses the github API to query the repository, get the list of pinned projects, then push in the generated HTML to the index.html. Perhaps even could use a simple templating engine, like Mustache.

Yes, it's possible to achieve this combination with a custom GitHub Action that both generates content dynamically and deploys to the gh-pages branch. But the first question to figure out is, can this special repo -- again, used as the org gh-pages deploy -- itself override its deployment with a custom gh-pages deployment? I haven't been able to find any documentation on whether this special case has such support, all the docs I found were either about doing custom actions for a normal repo, OR doing this special magic deployment of a repo for the org, not both together.

Yes! As long as byojs repository is set to deploy from the gh-pages branch (or /docs folder in main), you can override the content with a github workflow. The custom workflow will generate and push new content to the same branch that GitHub Pages uses for deployment.

QuantumAbraham commented 1 month ago

Here's how we can approach it: We can create a custom workflow (in .github/workflows) that triggers on push or a schedule (e.g., daily or weekly). In the workflow, we use the GitHub API to query the organization’s pinned repositories. Dynamically generate the content (e.g., an index.html) using a templating engine like Mustache or even just raw string manipulation. Deployment to GitHub Pages:After generating the content, use the same GitHub Action to commit the updated index.html or other generated files back to the gh-pages branch. GitHub Pages will automatically detect the update and deploy the site as usual.