Pat*_*ric 1 git gitlab gitlab-ci-runner
我试图找到解决这个问题的方法,但没有找到。
问题:
我们有图像文件/public/img/InfoNews/example.png,每次推送更新时 gitlab-runner 都会删除远程上的这些文件。
我们/public/img/InfoNews的.gitignore这可以防止 git 上传本地文件,但不能出于某种原因删除该文件夹中的远程文件。
我尝试将此路径添加到缓存和工件中,但.gitlab-ci.yml没有成功
朝着正确的方向推动是值得赞赏的。
我们的.gitlab-ci.yml:
cache:
paths:
- vendor/
- public/img/
deploy:
stage: deploy
script:
- php artisan cache:clear
- rm -rf vendor/
- composer install
- echo "$env" > "$(pwd)/.env"
- php artisan migrate
artifacts:
paths:
- .env
- public/img/
Run Code Online (Sandbox Code Playgroud)
编辑:
我也尝试过
cache:
untracked: true
paths:
- vendor/
- public/img/
Run Code Online (Sandbox Code Playgroud)
但它仍然删除文件。
我自己修好了。
Gitlab-runnergit clean在签出后运行,并.gitignore出于任何原因默认忽略文件。
为了防止文件被删除,您必须将其添加到您的 gitlab-ci.yml`:
variables:
GIT_CLEAN_FLAGS: -x -f -e public/**
Run Code Online (Sandbox Code Playgroud)
-x 忽略 .gitignore 文件 -f 强制清理,-e 从清理中排除文件,** 表示每个文件和文件夹