Introducing GitHub Actions Check Updates
Tags: githubactions, github, ci, devops
Published: 2020-04-30 09:08:57

# Introduction
Working on a project it's important to have all your dependencies up-to-date. New versions have new features, bug fixes and many other improvements.

There are a lot of tools that helps us to keep all dependencies up-to-date. For `maven` projects we have [Versions Maven Plugin](https://www.mojohaus.org/versions-maven-plugin/), where we can run
```bash
mvn versions:display-dependency-updates
```
and see something like:
```bash
[INFO] --- versions-maven-plugin:2.7:display-dependency-updates (default-cli) @ poe-runner ---
[INFO] The following dependencies in Dependency Management have newer versions:
[INFO]   com.github.fabasoad:commons-lang ...................... 0.2.3 -> 0.4.5
[INFO]   com.google.guava:guava .............................. 19.0 -> 29.0-jre
[INFO]   commons-cli:commons-cli ................................... 1.2 -> 1.4
```
For `npm` projects there are many other tools like [npm-check](https://www.npmjs.com/package/npm-check) or [npm-check-updates](https://www.npmjs.com/package/npm-check-updates), where we can run `ncu` and see something like this:
```bash
PS C:\Projects\MyProject> ncu
Checking C:\Projects\MyProject\package.json
[====================] 42/42 100%

 @babel/core           7.8.7  →  7.9.0 
 @babel/preset-env     7.8.7  →  7.9.5 
 @babel/preset-react   7.8.3  →  7.9.4 
 babel-loader          8.0.6  →  8.1.0 
 firebase             7.10.0  →  7.14.2

Run ncu -u to upgrade package.json
```
All such tools help us to keep our projects "healthy". But what about GitHub Actions? What if you have many workflow files with many GitHub Actions used there. It would be difficult to track all the versions manually. And here _GitHub Actions Check Updates_ comes to help you :wink:

# GHACU
_GitHub Actions Check Updates (GHACU)_ is a tool that helps you to keep versions of configured GitHub Actions up-to-date. Here is how it looks like in action:
```powershell
PS C:\Projects\linguist-action> ghacu
> Dockerfile Lint (.github\workflows\dockerfile-lint.yml)
actions/checkout               v2.0.0  »  v2.1.0
burdzwastaken/hadolint-action  master  »   1.1.0

> Shell Lint (.github\workflows\shell-lint.yml)
actions/checkout                v1  »  v2.1.0
bewuethr/shellcheck-action  v2.0.1  »  v2.0.2

> YAML Lint (.github\workflows\yaml-lint.yml)
ibiqlik/action-yamllint  v0.0.2  »  v1.0.0

Run ghacu -u to upgrade actions.
```
## Installation
All what you need to do is to go to [Releases page](https://github.com/fabasoad/ghacu/releases) and download latest release based on OS that you have. It supports MacOS, Linux and Windows.
### MacOS and Linux
```bash
# MacOS: ghacu-1.1.3-osx-x64.tgz
cd ~ && wget https://github.com/fabasoad/ghacu/releases/download/v1.1.3/ghacu-1.1.3-linux-x64.tgz
tar -xvf ghacu-1.1.3-linux-x64.tgz
cd ghacu-1.1.3-linux-x64
chmod 755 ghacu
PATH=$PATH:~/ghacu-1.1.3-linux-x64
```
### Windows
There are 2 options to install it on Windows:
1. Install it in the same way as for Linux/MacOS - download package, unpack it and add path to `PATH` environment variable.
2. Download executable file and just run it. Then add path to `PATH` environment variable.

## Usage
Once you install the tool, open your favourite console and run the command below. You should see installed version if you installed it correctly:
```powershell
PS C:\Projects\MyProject> ghacu --version
ghacu 1.1.3
```
At this moment it supports two options:
```powershell
PS C:\Projects\MyProject> ghacu --help
ghacu 1.1.3
Copyright (C) 2020 ghacu

  -r, --repository    Path to the root of a project.

  -u, --upgrade       Upgrade versions to the latest one.

  --help              Display this help screen.

  --version           Display version information.
```
### `-r`, `--repository` 
It's a path to the project that has `.github/workflows` folder inside, e.g. `C:\Projects\MyProject`. If you do not define it, path will be the current path where you run `ghacu`. Result is the same in examples below.
```powershell
PS C:\Projects\MyProject> ghacu
> CI (latest) (.github\workflows\ci-latest.yml)
actions/checkout  master  »  v2.1.0

> YAML Lint (.github\workflows\yaml-lint.yml)
ibiqlik/action-yamllint  v0.0.2  »  v1.0.0

Run ghacu -u to upgrade actions.
```
```powershell
PS C:\> ghacu -r "C:\Projects\MyProject"
> CI (latest) (.github\workflows\ci-latest.yml)
actions/checkout  master  »  v2.1.0

> YAML Lint (.github\workflows\yaml-lint.yml)
ibiqlik/action-yamllint  v0.0.2  »  v1.0.0

Run ghacu -u to upgrade actions.
```
### `-u`, `--upgrade`
Use this option if you want to update your actions to the newer versions. At first I propose you to run `ghacu` command without this option to see if newer versions look good to you and then run `ghacu -u`.
```powershell
PS C:\Projects\MyProject> ghacu -u
> CI (latest) (.github\workflows\ci-latest.yml)
actions/checkout  master  »  v2.1.0

> YAML Lint (.github\workflows\yaml-lint.yml)
ibiqlik/action-yamllint  v0.0.2  »  v1.0.0
PS C:\Projects\MyProject> ghacu
All GitHub Actions match the latest versions.
```
## Conclusion
I hope you will enjoy using this tool. As for me, I started using it from the beta version and enjoy using it as well as improving it. Feel free to post any feature requests or bug reports to the [Issues page](https://github.com/fabasoad/ghacu/issues), it will help me to keep making this tool better and better.
## Future
There are a lot of ideas to implement:
* Create `choco`, `brew`, `apt-get`, `apk` packages for easy installation.
* Add progress indicator, like:
```bash
[=================---] 38/42 86%
```
* Add support of `--revert`, `--parallel` and many other features.
* Add installation path to `PATH` environment variable automatically after installation.
* Support different colors in console output text.
* Many others.

It's written in C# .NET Core and if you are interested in contribution, you are very welcome to fork the repo and help to improve it :computer:

Repository:
https://github.com/fabasoad/ghacu