SaFi Bank Space : Doc - GitHub Actions - Study

GitHub Action’s core components:

Events:

GitHub Actions workflows are controlled by events and constitutes the following:

  1. Scheduled events

  2. Manual events

  3. Web-hook events

Scheduled events can trigger a workflow to run at a specified time. They use the POSIX cron syntax.

The example below shows part of a workflow file, written in YAML; the workflow will be triggered every 10 minutes. The minimum interval allowed by GitHub Action is 5 minutes.

on:
  schedule:
    - cron:  '*/10 * * * *'

Manual events is also an option to run workflows manually, although the most popular use case of GitHub Actions is to run workflows automatically.

It is possible to manually trigger two different types of manual events: workflow_dispatch and repository_dispatch.

The  workflow_dispatch event can be used to trigger specific workflows within a repository on GitHub manually. It also allows you to define custom input properties, as well as default and required inputs, from within the workflow file. You can then access those inputs using the github.event.inputs context. 

The following example shows part of a workflow file where the workflow_dispatch event is being used. It requires input from the user and prints the user's input to the logs:

To trigger the workflow_dispatch event, the workflow must be on the default branch.

on: 
  workflow_dispatch:
    inputs:
      username:
        description: 'Your GitHub username'
        required: true
      reason:
        description: 'Reason why we are running this workflow manually'
        required: true
        default: 'I am running tests before implementing an automated workflow' 

WebHook events

The GitHub web-hook events are types of events that trigger a workflow when issue and pull request creation, update and deletion, deployment, push, and others are created.

Note the example below:

# example safibank project in github

on:
  push:
    paths:
      - app/**
      - .github/workflows/safi-mobile-app-ci.yml
      - .github/workflows/safi-mobile-analyze-test-ci.yml
    branches:
      - main
    tags:
      - "*"
    
  pull_request:
    paths:
      - app/**
      - .github/workflows/safi-mobile-app-ci.yml
      - .github/workflows/safi-mobile-analyze-test-ci.yml
    #TODO: change with main branch
    branches:
      - main   

To simplify and avoid plagiarism, I will just reference the a URL of the documentation, instead of copy paste.

https://docs.github.com/en/actions/quickstart

https://docs.github.com/en/actions