php - Gitlab CI如何部署PHP?

标签 php deployment gitlab gitlab-ci

我使用 gitlab、gitab-ci,我对持续集成还很陌生。我尝试在代码推送时通过 bash 脚本进行测试和部署。

这就是我的 .gitlab-ci.yml 在部署时的样子我尝试更改用户但不会工作

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

这里我有 bash,如果测试通过,它应该在生产站点上提取代码

#!/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

我试图通过 google 查找一些与 php 相关的示例,但没有成功。有人可以展示应该如何工作吗

最佳答案

尝试用 sudo -Hu 替换 su -c

关于php - Gitlab CI如何部署PHP?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37653026/

相关文章:

php - Cookie - PHP 与 Javascript

ios - Swift 4 - 设置最低部署目标

eclipse - 在 Eclipse 中自动化 JBoss 部署?

docker - 检索https://nvd.nist.gov/feeds/json/cve/1.0/nvdcve-1.0-2020.meta时出错;收到回应码404

php - Laravel 受影响的行

php - mysql - 匹配日期时间字段的年份数组

php - 在php中排序整数值

tomcat - 从 Intellij 在 tomcat 中将 Web 应用程序部署为 ROOT.war 应用程序

git - 如何将存储库从 GitLab 7.9.0 迁移到 GitLab 社区版 11.8.3?

gitlab - 如何将 GitLab 迁移到新服务器?