Search code examples
githubyamlgithub-actionsgithub-pages

How can I create multiple GitHub pages in one repository under different branches?


I have a published page created under the gh-pages branch, but I'm needing to publish other GitHub pages for my test reports in other instances from other branches for viewing in one repo.

For example I need the test report for a dev instance to publish a page from gh-pages-dev branch while I could user another page in gh-pages-qa branch for the qa instance.

I'm using https://github.com/peaceiris/actions-gh-pages to publish my page with the specified branch. If I specify a branch to publish from it will just overwrite the page with the same url.

I don't think this is currently possible given the below GitHub issues thread and it being worked on, but if someone has an alternative solution I would love to hear it https://github.com/github/pages-gem/issues/724 .


Solution

  • I found a workaround for my needs. I used different files in the gh-pages branch to show different pages/test reports.

    In the Github Pages docs here it states the following:

    You can add more pages to your site by creating more new files. Each file will be available on your site in the same directory structure as your publishing source. For example, if the publishing source for your project site is the gh-pages branch, and you create a new file called /about/contact-us.md on the gh-pages branch, the file will be available at https://.github.io//about/contact-us.html

    So with that I publish my test report html into different directories/folders and you can navigate to them as described in the documentation provided. You just need to keep the files so the directory stays there and you can commit and update the directory with each new run.

    specificly for me I am using spock with geb to get test reports so I state the directory like so in my SpockConfig File.

    'com.athaydes.spockframework.report.outputDir': "build/geb-spock-reports/envNameHere"
    

    Example:

    • Dev Test Report Page Url
      • https://pages.your.github.com/ghOrganizationHere/ghRepoHere/dev/index.html
    • QA Test Report Page Url
      • https://pages.your.github.com/ghOrganization/ghRepoHere/qa/index.html

    GH Action Example:

          - name: Deploy Page
            uses: peaceiris/actions-gh-pages@v3
            with:
              github_token: ${{ github.token }}
              publish_dir: build/geb-spock-reports/envNameHere
              publish_branch: gh-pages
              keep_files: true