GitHub Actions is a continuous integration and continuous delivery (CI/CD) platform that allows you to automate your build, test, and deployment pipeline. [Github]

Intro

Github is:

  • Cloud repository storage (push, pull);
  • Code management and collarative development (issues, projects, PR);
  • Automation and CI/CD (github actions, github App)

Workflow automation service in Github automate all kinds of repository-related process and actions around the code inside the repositories

  • Code Deployment: CI (code changes are automatically built, tested and merged with existent code) and CD (publishing new version of App after the integration - automate code testing, building, deployment)
  • Code and repository Management: Automate code reviews, issue management, etc

Fork:

  • The feature that clone a repository for another github account
  • The target account will have its own repository on github based in another github repository
  • It makes possible to create a PR from an account to the original repo


Key Elements

Workflow: [1]

  • Workflows are attached to repositories.
  • The first step to the automation process is create a workflow.
  • It includes one or more jobs.
  • It can be executed after an event
  • You can create a new one by Action menu [1.1]

Job: [2]

  • It is a process to be executed
  • Every job define runner (a execution environment - machine and OS) [2.1]
  • A workflow can have multiple jobs and every job gets its own runner (it's own virtual machine)
  • The jobs are executed in parallel as default, or can configure to sequencial order.
  • Also is possible add condicional to run a job.
  • Jobs have steps that will be executed in the order of their definition
  • Job Artifacts (output files, etc): used for sharing log file, app binary, etc [2.2]

Step:

  • The steps define what will be done (download, install dependencies, etc).
  • Step is a shell script (command in command line that should be executed) or an action (another building block).
  • It can have conditions

Action: [3]

  • It is a predefined script that perform a task.
  • A typically complex frequently repeated task
  • You can use your own or can use a third party actions
  • Marketplace is where you can find common actions [3.1]

Event: (Workflow Triggers) [4]

  • The events define when a given workflow will be executed [4.1]
  • Repository-related: push, PR, create, fork, issues, issue_comment, watch, discussion
  • Otther: workflow_dispatch, repository_dispach, schedule, workflow_call
  • By default, PRs based on forks do NOT trigger a workflow for sacirity reasons

Here is an example how it works. The image bellow you can see the sequence of jobs being executed (test, deploy, download and report) and others two in a parallel execution. If one of the sequencial steps fail the other jobs in the sequence will not be executed.


The code that represent the image you can see in github repo. You can read more detail about the file here: Understanding the workflow file.


More

Contexts: are a way to access information about workflow runs, variables, runner environments, jobs, and steps. [Context]

Expressions: use it to programmatically set environment variables in workflow files and access contexts. [Expressions]

Default environment variables: are available to every step in a workflow [Default Variables].

Custom Action: You can customize your own actions using different approaches [Custom Action]

  • JavaScriptActions (node_module us bit ignired but pushed)
  • Docker Actions
  • Composite Actions

Reuse: The workflows can be reused to avoid duplication [Reuse].

Cache:It's possible to use cache to use something already done and avoid do the same process again [Cache].

Secrets: It allows to have secrets that can be the same or change by environment [Secrets].

Matrix strategy: run same job in different configuration. Jobs are executed in parallel [Matrix].

Security and Permissions


References