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!

Image of Quadratic

Free AI chart generator

Upload data, describe your vision, and get Python-powered, AI-generated charts instantly.

Try Quadratic free

Top comments (1)

Collapse
 
robertobutti profile image
Roberto B.

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

Jetbrains image

Is Your CI/CD Server a Prime Target for Attack?

57% of organizations have suffered from a security incident related to DevOps toolchain exposures. It makes sense—CI/CD servers have access to source code, a highly valuable asset. Is yours secure? Check out nine practical tips to protect your CI/CD.

Learn more

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay