Link Search Menu Expand Document

Github Actions: Workflow 04 - Rebuild content of gh-pages branch (part 2)

Workflow 04-gh-pages-rebuild-part-1.yml is triggered immediately after 02-gh-pages-rebuild-part-1.yml completes.

The purpose of 04-gh-pages-rebuild-part-2.yml is to copy the artifacts built by 02-gh-pages-rebuild-part-1.yml to where they belong on the gh-pages branch so that the site can be deployed.

It uses these Github Action frequently:

dawidd6/action-download-artifact@v6

The action dawidd6/action-download-artifact@v6 is used to retrieve the artifacts stored by 02-gh-pages-rebuild-part-1.yml into the working disk storage of the virtual machine running the Github Action.

Here’s an example:

    - name: a-javadoc Download artifact
      uses: dawidd6/action-download-artifact@v6
      with:
        workflow: 02-gh-pages-rebuild-part-1.yml
        github_token: $
        name: javadoc
        path: $
        check_artifacts: true
        if_no_artifact_found: error

Here:

  • name should match the name in 02-gh-pages-rebuild-part-1.yml under which the artifact was stored
  • path should match where the contents of the .zip file in the artifact should be unzipped and stored in the temporary file storage of the virtual machine running the job.

JamesIves/github-pages-deploy-action@v4

The action JamesIves/github-pages-deploy-action@v4 is used to take the unzipped contents from the dawidd6/action-download-artifact@v6 step, and store them somewhere in the gh-pages branch for deployment to the Github Pages site.

Here’s an example:

    - name: a-javadoc Deploy Javadoc (Main) 🚀
      uses: JamesIves/github-pages-deploy-action@v4
      with:
        branch: gh-pages # The branch the action should deploy to.
        folder: $ # The folder where we put the files
        clean: true # Automatically remove deleted files from the deploy branch
        target-folder: javadoc # The folder that we serve our files from

Here:

  • folder is the place where the previous step (i.e. the dawidd6/action-download-artifact@v6 step) put the files on the local temporary file system where the workflow is running)
  • target-folder is where the files should be placed on the gh-pages branch.