Commit to master when pipeline complete

Hello, i wonder if it is possible to commit to master branch when a pipeline is totaly completed. I make tests in my pipeline so i want it to push on master if all tests passed.

Here is my .gitlab-ci.xml:

stages:

  • building
  • testing
  • deploy

variables:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: laravel
DB_HOST: mysql
DB_CONNECTION: mysql
DB_DATABASE: laravel
DB_USERNAME: root
DB_PASSWORD: root

image: edbizarro/gitlab-ci-pipeline-php:7.4

cache:
key: “$CI_JOB_NAME-$CI_COMMIT_REF_SLUG”

composer:
stage: building
script:
- php -v
- composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
- cp .env.example .env
- php artisan key:generate
artifacts:
paths:
- vendor/
- .env
expire_in: 1 days
when: always
cache:
paths:
- vendor/

unit_tests:
stage: testing

services:
- name: mysql:5.7

dependencies:
- composer
script:
- mysql --version
- php artisan migrate:fresh --seed
- mysqldump --host=“$DB_HOST” --user=“$DB_USERNAME” --password=“$DB_PASSWORD” “$DB_DATABASE” > db.sql
- ./vendor/bin/phpunit --coverage-text --colors=never
artifacts:
paths:
- storage/logs # for debugging
- db.sql
expire_in: 1 days
when: always

deploy:
stage: deploy

script:
- push to master

i’ve seen that someone add an ssh key to pull and commit from the docker but i’m not a fan of this method so if someone have another…
any idea?

Hi @Grainbox

from the pipeline it is not clear what do you want to achieve. That pipeline runs also if someone pushes to master branch so you will create a loop that way. Maybe use Merge Requests instead?