Skip to main content

GitHub Actions


Use the YAML extension for VSCode to have autocomplete and validation.


Always specify the action version, eg actions/checkout@v3 instead of actions/checkout, otherwise the pipeline can suddenly break with a new release of the action. Rationale




Run your GitHub Actions locally -

GitHub hosted runners preinstalled software:



name: Print CI environment variable
on: [push]
runs-on: ubuntu-latest
- uses: actions/checkout@v3
- run: echo "$CI"

From Understanding GitHub Actions.

Event - on

GitHub Actions goes beyond just DevOps and lets you run workflows when other events happen in your repository. For example, you can run a workflow to automatically add the appropriate labels whenever someone creates a new issue in your repository.

An event is a specific activity in a repository that triggers a workflow run. For example, activity can originate from GitHub when someone creates a pull request, opens an issue, or pushes a commit to a repository. You can also trigger a workflow run on a schedule, by posting to a REST API, or manually.

For a complete list of events that can be used to trigger workflows, see Events that trigger workflows.


Your workflow contains one or more jobs which can run in sequential order or in parallel. Each job will run inside its own virtual machine runner, or inside a container, and has one or more steps.

Job - jobs -> steps -> run/uses

A job is a set of steps in a workflow that execute on the same runner. Each step is either a shell script that will be executed (run), or an action that will be run (uses). Steps are executed in order and are dependent on each other. Since each step is executed on the same runner, you can share data from one step to another. For example, you can have a step that builds your application followed by a step that tests the application that was built.

You can configure a job's dependencies with other jobs; by default, jobs have no dependencies and run in parallel with each other. When a job takes a dependency on another job, it will wait for the dependent job to complete before it can run.

Action - uses

An action is a custom application for the GitHub Actions platform that performs a complex but frequently repeated task. Use an action to help reduce the amount of repetitive code that you write in your workflow files. An action can pull your git repository from GitHub, set up the correct toolchain for your build environment, or set up the authentication to your cloud provider.

You can write your own actions, or you can find actions to use in your workflows in the GitHub Marketplace. For more information, see "Creating actions."

Runner - runs-on

A runner is a server that runs your workflows when they're triggered. Each runner can run a single job at a time. Each workflow run executes in a fresh, newly-provisioned virtual machine.

GitHub provides Ubuntu Linux, Microsoft Windows, and macOS runners to run your workflows. If you need a different operating system or require a specific hardware configuration, you can host your own runners.



Midudev - GitHub Actions TUTORIAL Desde Cero - Integración continua (CI/CD) - - Repository:

How to build a CI/CD pipeline with GitHub Actions in four simple steps:

7 advanced workflow automation features with GitHub Actions:

GitHub Actions Pitfalls -

Commonly used actions

Marketplace most starred/installed actions:

Sample and available actions



Official starter workflows:

Interesting workflows


ESLint actions

AWS actions

Note that GitHub runners already come with the AWS CLI installed, see

AWS S3 actions


OpenID Connect

Use it to authenticate to cloud services (like AWS) without storing long-lived secrets (like access key ID and secret access key) in GitHub.

About security hardening with OpenID Connect -

using hardcoded secrets requires you to create credentials in the cloud provider and then duplicate them in GitHub as a secret.

With OIDC, your cloud provider issues a short-lived access token that is only valid for a single job, and then automatically expires.

Configuring OpenID Connect in Amazon Web Services -

See the examples at In particular see the workflow

Creating OpenID Connect (OIDC) identity providers -

Creating a role for a third-party Identity Provider (federation) -

Run a single job at a time

Example from that ensures only one GitHub pages concurrent deployment:

# Allow only one concurrent deployment
group: 'pages'
cancel-in-progress: true

Run only if a folder or file has changed

Use the paths filter:

branches: [main]
- src/**
- package.json

See Patterns to match file paths for how to write the paths.


Run job only when a folder changes -

There's also paths-ignore that instead excludes.

Note that "You cannot use both the paths and paths-ignore filters for the same event in a workflow", but you can use ! to negate/exclude and achieve the same.

Change directory

Use working-directory, eg:

# If you use 'defaults' it applies to all 'run' steps in a workflow
working-directory: web

Running actions in another directory -

Docs (search for working-directory):

Re-use actions

Reusing workflows -

Creating a composite action -


Adding a workflow status badge -

Example of badge on the README:

Badge actions on the marketplace: