This is the last chapter on creating a PHP package. It will be a quick overview of github actions without details and in the end I will provide a final script for the flow.
Github actions is built-in into github and allows easily create custom workflows in repositories. It can run specific command when a certain event is accrued.
To initialize a github actions, you need to create a .yml file in you repo under the folder ".github/workflows/". The name of the file can be any. I called it "php_ci.yml".
This file consists of 4 main parts:
I want to run a pipeline when someone creates a pull request or push changes to the master branch.
I will split my workflow into two jobs:
run code style check.
We already have commands for that in composer.json.
Besides that, I want to run my jobs on two php versions: 8.1 and 8.2. And my actions/commands are:
setup php with pre-build action.
check php version
checks-out current repository under $GITHUB_WORKSPACE to let the workflow can access it.
validate composer.json and composer.lock
run composer install
Run PHPUnit / linter
You can find full file below:
Now each pull request or push to the master branch will trigger this workflow. You can check output on the actions page:
For now that's all I wanted to tell about php package development. If you have questions, as always, please, leave a comment. Thank you for reading these articles. I hope you have found something useful and maybe learned something new.