DEV Community

Cover image for Laravel 7 and GitHub actions
Roberto B.
Roberto B.

Posted on • Edited on

1

Laravel 7 and GitHub actions

With Github actions you can automate some specific tasks and you can execute them on a dedicated environment.

Suppose that you have a Laravel application on a Github repository and you want to execute the test suite (via phpunit) every time you push your code on master branch.

From the Github repository page, click on “Actions”.

Actions tab

On Actions section you can create and manage your workflow.

A workflow is a set of steps that it will be execute once you perform a specific action on your repository, for example push your code on master branch.

To create a new workflow, in the action section, click on the “New workflow” button.

Create a new workflow

Github detects automatically the language and/or the framework used in your application. In this case if you have a Laravel application, you can start from the Laravel workflow template.

You can select the Laravel Workflow Template

This is a very simple configuration but very useful to start quickly.

Click on “Set up this workflow” to select Laravel basic workflow.

A new file “.github/workflow/laravel.yml” is created for you, in your repository. You can change your file in order to accomodate your needs.

If you want to understand better all directives in the file, I suggest you to read my Medium post: https://medium.com/@robertodev/continuous-integration-with-github-actions-and-laravel-6-e6cb9aa5aea9

For now, you can publish your actions clicking on “Start commit” button.

Commit and Push your changes

To see your new Workflow, click again on “Actions” tab.

On the left panel you can see the list of your workflows, in this case you will have just one workflow named Laravel.

In the main table you will see the list of workflows executed. The first workflow is the more recent.

If you click on the workflow executed, you can access in the workflow detail page. Selecting the action you can see the log and the list of the steps executed. Green is good , red is bad ;)

Now, every time you push your code on master branch, the test suite will be executed automatically. If the workflow will fail you will be notified with an error and you will receive also an email.

I created also a video tutorial for Github actions + Laravel

Feedbacks are welcome!

Heroku

Deploy with ease. Manage efficiently. Scale faster.

Leave the infrastructure headaches to us, while you focus on pushing boundaries, realizing your vision, and making a lasting impression on your users.

Get Started

Top comments (1)

Collapse
 
robertobutti profile image
Roberto B.

I created also a video tutorial about Github Actions and Laravel: youtu.be/llslbekD0_M

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

👋 Kindness is contagious

If this article connected with you, consider tapping ❤️ or leaving a brief comment to share your thoughts!

Okay