Skip to main content
Skip table of contents

GitHub Workflows

New Golive GitHub Actions are now available make this integration easier to implement.

This page shows an example of integration between Golive Server/DC and GitHub Workflows.

To be able to push information, here deployments, you’ll need:

  • an accessible Jira instance from outside of your organization

  • a user name and password of a user that has the required permission

  • an environment set up in Golive

  • an existing GitHub workflow

To illustrate, we’ll use the Workflow of our Golive Monitor product as an example.

The existing Workflow builds a docker image and pushes it to the Docker hub (Golive monitor).

At the end of the Workflow, we want to add a deployment to the corresponding environment on Golive:

Creating the Github secret(s)

First, we need to store the password as a secret in github:

In Actions, click on “new repository secret” (top right of the screen), add the key in the field named secret.

The chosen name (here JIRA_PASSWORD) will be used to retrieve the secret in the yaml workflow file.

Whether the username needs to be stored as a secret too, is a personal choice. We will not do it here

Adding the Golive update step in the Workflow

In the Github Workflow file that describes the build we add the following snippet as the last step of the build:

YAML
      - name: Push new deployment to Golive
        uses: fjogeleit/http-request-action@v1
        with:
            url: 'https://my.jira.example.com/rest/apwide/tem/1.1/deployment?environmentId=61'
            method: 'PUT'
            username: 'ci-user'
            password: ${{ secrets.JIRA_PASSWORD }}
            customHeaders: '{"Content-Type": "application/json"}'
            data: '{
                "versionName": "${{ env.today }}-${{ steps.commit.outputs.short }}",
                "description": "Github Workflow automated release\n\n
                    ➙ https://hub.docker.com/repository/docker/apwide/golive-monitor/general\n\n
                    ➙ https://github.com/apwide/golive-monitor/commit/${{steps.commit.outputs.short}}"
            }'

We use the fjogeleit/http-request-action action to perform our call the Golive API.

Line 4, the environment id (61) is hard-coded, this could also be a variable in the code or in the repository.

The token is added on line 7 with the ${{ secrets.JIRA_PASSWORD }}.

In our example, line 10, we use a release version name that looks like 2023-02-01-2323gfj. We add a description that acts like some sort of signature. The result can be seen in the image at the top of this page.

The full Workflow script

NOTE that we are using Jira Cloud so the repository contains the https://apwide.atlassian.net/wiki/spaces/GOLIVESERVER/pages/467534137 version.

This script is available in the Golive Monitor repository. This needs to be in .github/workflows.

YAML
name: build docker image

on:
  push:
    branches:
      - main

jobs:
  docker:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - id: commit
        uses: pr-mpt/actions-commit-hash@v2
      - id: date
        run: |
            echo "today=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
      - name: Login to Docker Hub
        uses: docker/login-action@v2
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}
      - name: Build and push
        uses: docker/build-push-action@v4
        with:
          context: .
          push: true
          tags: apwide/golive-monitor:latest,apwide/golive-monitor:${{ env.today }}-${{ steps.commit.outputs.short }}
      - name: Push new deployment to Golive
        uses: fjogeleit/http-request-action@v1
            url: 'https://my.jira.example.com/rest/apwide/tem/1.1/deployment?environmentId=61'
            method: 'PUT'
            username: 'ci-user'
            password: ${{ secrets.JIRA_PASSWORD }}
            customHeaders: '{"Content-Type": "application/json"}'
            data: '{
                "versionName": "${{ env.today }}-${{ steps.commit.outputs.short }}",
                "description": "Github Workflow automated release\n\n
                    ➙ https://hub.docker.com/repository/docker/apwide/golive-monitor/general\n\n
                    ➙ https://github.com/apwide/golive-monitor/commit/${{steps.commit.outputs.short}}"
            }'

Only lines 30 to 37 are specific to Golive, the rest is just preparing for the build.

We use the combination of the date and the short commit hash to build our version name.

  1. Checkout (12-13)

  2. Retrieve commit hash (14-15)

  3. Build a date string and add it the env (16-18)

  4. Build the docker image and upload it (24-29)

  5. Pushing the deployment to Golive (30-42)

Troubleshooting

If the final action fails check the action tab in Github to read the output of the command. It might give a hint on what is not working.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.