GitHub Actions Example

Prerequisites

  • Access to a GitHub account and project. Sign up for free here.
  • Git must be set up and configured in your Coalesce Org. To use GitHub Actions, you must use GitHub as your git repository.

Upload Actions Secret

To follow best practices, Coalesce recommends that you upload your coa config file as a secure file within the GitHub Actions settings.

  1. From within your GitHub project, go to Settings Secrets Actions
28762876

Location of GitHub secrets

  1. Click New repository secret
  2. Provide a name for it. In this example we will call it COA_CONFIG
  3. Find and open your coa config file. Default location is ~/.coa
  4. Copy its contents into the Value field
  5. Click Add Secret to save

Create a Workflow

  1. From within your GitHub project, go to Actions and click New workflow
  2. Choose Simple workflow Configure
  3. You will be presented with a template YAML file. Provide it a name and replace its content with the Refresh Workflow code below.

📘

On the YAML Example Code

The below is an example of an hourly refresh, although it could be modified to trigger a deployment off of a commit to a specified branch, perform a daily refresh, or many other options.

name: Refresh Data

on:
  # Set a schedule using cron
  schedule:
  - cron: "0 * * * *"
  
  # This option allows the workflow to be triggered manually
  workflow_dispatch:
  
env:
  COA_VERSION: latest # Versions released on NPM here: https://www.npmjs.com/package/@coalescesoftware/coa
  
jobs:
  build:
    runs-on: ubuntu-latest
    
    steps:
    - uses: actions/[email protected]
    - uses: actions/[email protected]
      with:
        node-version: 18
    
    # Fetch coa config secret from GitHub Actions secret repository, then write coa config to a temporary file
    - run: echo '${{ secrets.COA_CONFIG }}' >> COA_CONFIG
    
    # Install Coalesce CLI tool, if not installed already
    - run: npm list | grep "@coalescesoftware/[email protected]${{ env.COA_VERSION }}" || npm install @coalescesoftware/[email protected]${{ env.COA_VERSION }}

    # Execute coa CLI, starting coa refresh
    - run: npx coa refresh --config COA_CONFIG
  1. Commit this file to your repository
  2. You'll now see your workflow, and it will automatically run every hour. You can also manually run it by clicking Run workflow.
32243224

Refresh workflow


What’s Next
Did this page help you?