GitHub Actions

◷ Reading Time: 5 minutes

GitHub Actions is a continuous integration and continuous delivery (CI/CD) platform that allows you to automate your build, test, and deployment pipeline. Run a workflow on any GitHub, event Kick off workflows with GitHub events like push, issue creation, or a new release.

For this scenario, we use the sample project ‘delivery cost calculator’ which has some Tests to run and a sample decision table to publish/deploy. the purpose is to create a workflow that triggers when we push new changes to a GitHub repo

Create a GitHub repo

1.1 Follow the resource page to create a GitHub repo.

Version Control Archives – FlexRule Resource Hub

1.2 Add the repo to an FRD project remote repo.

Add a self-hosted GitHub runner

2.1 Add a self-hosted GitHub runner on a windows machine.

follow this instruction: Adding self-hosted runners – GitHub Docs

2.2 Confirm the runner is connected. GitHub->the Repo->Settings->Runners

There are two options available to provision GitHub runners, GitHub-hosted runners, and self-hosted runners

Create a GitHub workflow

3.1 Create a workflow under GitHub->the Repo->actions.

3.2 Select simple config and edit the default .yml actions.

3.3 Copy the below code under “edit new file” then “Start commit”.

name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on: [push]
jobs:
  Explore-GitHub-Actions:
    runs-on: runner1
    steps:
      - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." 
      - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!." 
      - name: Check out repository code        
        uses: actions/checkout@v3        
      - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." 
      - run: echo "🖥️ The workflow is now ready to test your code on the runner." 
      - name: List files in the repository
        run: |
          dir ${{ github.workspace }} 
      - run: ${{ github.workspace }}\test.bat      
      - run: ${{ github.workspace }}\publish.bat
      - run: echo "Project published successfully"
      - run: ${{ github.workspace }}\deploy.bat
      - run: echo "Project deployed successfully"     
      - run: echo "🍏 This job's status is ${{ job.status }}."      

Some of the above actions are:

  • on: [push] : it triggers when we push changes to this repo
  • runs-on: runner1 : this is the name of the self-provisioned runner which runs the activities (which we set up in step 3)
  • uses: actions/checkout@v3 : this is to clone the repo
  • - run: ${{ github.workspace }}\*.bat : runs the batch files that are attached to the FRD project
FRDx sample project

4.1 Open delivery cost calculator sample.

Delivery Cost Calculator – FlexRule Resource Hub

4.2 Add three batch files to the project as below.

  • Publish.bat: add your FlexRule CLI publish command to publish the project to the .frdp package file e.g
cd %cliPath%
fr.exe publish "%settings%"

All input/output parameters that we use for CLI commands should be read from the GitHub runner work path; For that purpose, we attach a runtime license to the project as well.

  • Deploy.bat: add your FlexRule CLI deploy command to deploy the above .frdp package file on the AWS cloud e.g
cd %cliPath%
fr.exe deploy "%settings%"
  • Test.bat: add your FlexRule CLI test command to run the attached Test Cases e.g
cd %cliPath%
fr.exe test "%settings%"

4.3 Do a few changes in your decision table and commit/push.

4.4 you can see workflow triggers, click on it and select “Explore” to see details.

4.5 check the deploy.bat output to find the new deployed function execute Url.

Updated on November 23, 2022

Was this article helpful?

Related Articles