Pipeline with Github Actions

Github Actions

Github Actions are a continuous integration and continuous delivery (CI/CD) platform for running automated building, test, and deployment pipelines.

Generating static pages is of course a major element of using static site generators. When working on a site, typically it is generated often, so it pays to streamline this step. When working locally regeneration can be automatic with pgn --serve <environment> command, but for production a deployment pipeline is a common approach. The following will explain how the pipeline setup for this site which uses Github Actions.

Overview pagegen.phnd.net pipeline

Once content is created and pushed to the pagegen.phnd.net repository, Github looks for any defined workflows and finds .github/workflows/deploy_site.yml. The deploy_site.yml file is used by Github Actions to build the site, basically running the regular pgn command. A deploy hook uploads the site to the web server, in this case using FTP.

Dcontent Createcontent push Push toGithub repository content->pushaction Github Actiongenerates site push->actionsiteSitedeployed action->site

deploy_site.yml highlights

The following describes key aspects of the workflow configuration. Github of course provides full documentation.

First conditions for running the workflow are defined, in this case a push to the master branch will trigger the workflow.

name: Deploy pagegen.phnd.net
      - master

Further the job steps are defined, the first few basically choose Ubuntu as OS, install Python and checkout the repository so it is available for generation and installs pagegen.

    name: Deploy site
    runs-on: ubuntu-latest
    - name: Install Python
      uses: actions/setup-python@v2
        python-version: 3.8
    - name: Checkout website source
      id: checkout-master
      uses: actions/checkout@v2
    - name: Install Pagegen
      run: |
        pip install pagegen

The next step is to run the pagegen command on the checked out repository (the Checkout website source step above) and finally to upload the site to FTP server. The FTP upload is implemented as a script that gets run by Pagegen's deploy_hook.

    - name: Generate site
      id: run-pagegen
      run: |
        cd /home/runner/work/pagegen_site/pagegen_site
        pgn -g "prod"

Because security the deploy script is made to look for sensitive information in the Actions environment. These encrypted secrets become environment variables available during the workflow. They are managed from the Github site.

To summarize a simple git push command will update the web site.