DEV Community

Cover image for You should try GitHub Actions Now!
Pedro Mutter
Pedro Mutter

Posted on

You should try GitHub Actions Now!

Introduction

Talking to my teammates here at Catho, a discussion arose about the tests and linters that should be run by the reviewers when there was a new PR in our new project.

We know that there are several tools that automate this process, but our use case is very specific and we would need to keep opening calls to ask for authorization to install these tools/bots. Then someone commented on GitHub Actions.

I had heard of them, but I had no idea of their flexibility and simplicity, I decided to study a little about them and then I had an idea to create an action that would solve our use case and still help me to understand how a GitHub Action works. And so VAR.js was born, if you can give it a star, I'll be happy 😊.

VAR.js in "action":
VAR.js in action

Create your own!

GitHub gives awesome documentation that you can easily get started with only it to create your own action, take a look.

If you want to create your action but is lazy to follow the documentation, GitHub also provides a very funny and interactive course to create your first hello-world action, you can do it in less than an hour and at the end, you will have a ready functional basic structure of an action project, take a look.

If you want a little more motivation, GitHub is also promoting a hackathon just about actions, if you have a good idea, I really encourage you to hurry and submit your action, entries will be accepted until 31/03, check it now.

Using an action

To use an action is very very very simple. You only need to create a folder on your project root called .github and inside it, another folder called workflows, and then inside this folder, you will create a YAML file, containing specifications of the actions you want to run and when, here are an example:

name: Your workflow
on:
  - push
  - pull_request
jobs:
  lint:
    name: Linting project
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: VAR.js
        uses: MutterPedro/varjs@v1.0.1
        with:
          SCRIPT: "format"

Here I am running my action VAR.js when there is a new push or a pull request in my project. You can find more information about the meaning of these specifications and folders pattern on the documentation and the course I mentioned above.

Conclusion

In addition, I was delighted with GitHub Action and strongly bet on its growth in the near future. We already have a huge diversity of actions, but it is just the beginning.

Top comments (0)