Gitlab CI how to deploy PHP?

I use gitlab, gitab-ci, and I'm brand new for continuous integration. I am trying to test and deploy a bash script when I press a key.

that my .gitlab-ci.yml looks like when I deploy, I try to change the user, but I won’t work

before_script:
  - composer install --prefer-dist > /dev/null

stages:
  - build
  - test
  - deploy


unitTesting:
  stage: test
  script:
    - echo "Running PHPUnit Tests"
    - php vendor/bin/phpunit --colors --debug  --coverage-text

job_deploy_master:
  stage: deploy
  only:
    - master
  script:
    - /bin/su - myuser -c "deploy.sh" //here I try to change linux user to be able to checkout code but fails with  **su: must be run from a terminal**
  tags:
    - php

and here I have bash that should pull codes at the production site if the tests pass

#!/bin/bash

echo "Starting Deploy"
printf '%s\n' "${SUDO_USER:-$USER}" //I'm interested to see which user try to run this script outputs gitlab-runner
cd /home/builds/gpx-convertor
git pull
composer install --prefer-dist > /dev/null

I tried google to find some php related examples, but without success. Can someone show how this should work

+4
source share
1 answer

Try replacing su -c with sudo -Hu

+1
source

All Articles