Install act on Ubuntu 22.04

Install act on Ubuntu 22.04

The act is a command line tool that allows to run GitHub Actions in local environment. It reads .github/workflows and determines the set of actions that need to be run. The act is based on Docker.

This tutorial shows how to install act on Ubuntu 22.04.

Prepare environment

You must have Git and Docker installed in the system:

No.SoftwareInstallation instructions
1.GitRead
2.DockerRead

Install act

Run the following command to download the tar.gz. file from releases page of the act repository:

wget -qO act.tar.gz https://github.com/nektos/act/releases/latest/download/act_Linux_x86_64.tar.gz

Extract act executable file to /usr/local/bin directory:

sudo tar xf act.tar.gz -C /usr/local/bin act

Now the act command can be used for all users as a system-wide command.

We can check act version as follows:

act --version

Remove tar.gz file:

rm -rf act.tar.gz

Testing act

Clone the sample repository for testing:

git clone https://github.com/cplee/github-actions-demo.git

Run the act command and specify working directory with -C option to run GitHub Actions locally:

act -C github-actions-demo

For the first time, you will be asked to choose the image to be used as default. You can select Medium size image. It can be changed later in ~/.actrc configuration file.

The act run jobs defined in YAML file which stored in github/workflows directory:

[CI/test] Start image=ghcr.io/catthehacker/ubuntu:act-latest
......
[CI/test] *  Run actions/checkout@v2
[CI/test]   Success - actions/checkout@v2
[CI/test] *  Run actions/setup-node@v1
......
[CI/test]   Success - actions/setup-node@v1
[CI/test] *  Run npm install
......
[CI/test]   Success - npm install
[CI/test] *  Run npm test
......
|   GET /
|     ✓ should respond with hello world
|
|
|   1 passing (28ms)
|
[CI/test]   Success - npm test

Uninstall act

If act is no longer needed, remove the executable file:

sudo rm -rf /usr/local/bin/act

You can also remove configuration file and cache:

rm -rf ~/.actrc
rm -rf ~/.cache/act

Leave a Comment

Cancel reply

Your email address will not be published.