CI deploy specific branch not working. Checking out to specific branch gets file from master anyway
I'm using Php deployer library to deploy my project.
I want to deploy to staging or production environment only in certain circumstances.
I configured gitlab-ci.yml to deploy to staging only when a commit is pushed on the staging
branch and to deploy to production only when a tag is pushed.
image: php:7.2-fpm-alpine
cache:
paths:
- vendor/
variables:
COMPOSER_ALLOW_SUPERUSER: 1
stages:
- deploy
before_script:
...
deploy_to_staging:
stage: deploy
only:
- staging
script:
- vendor/bin/dep deploy staging
deploy_to_production:
stage: deploy
only:
- tags
script:
- vendor/bin/dep deploy production
When the pipeline runs for staging deploy, seems to checking out to the branch staging
, but on server I find the files from branch master
Running with gitlab-runner 13.0.0-rc1 (f319718d)
on docker-auto-scale 72989761
Preparing the "docker+machine" executor
00:17
Using Docker executor with image php:7.2-fpm-alpine ...
Pulling docker image php:7.2-fpm-alpine ...
Using docker image sha256:515e9a15eafb1661d0045a653947c79fe22024ab20abc23276dd901916e3ef57 for php:7.2-fpm-alpine ...
Preparing environment
00:03
Running on runner-72989761-project-8257525-concurrent-0 via runner-72989761-srm-1589447902-cad4a737...
Getting source from Git repository
00:01
$ eval "$CI_PRE_CLONE_SCRIPT"
Fetching changes...
Initialized empty Git repository in /builds/project/api/.git/
Created fresh repository.
From https://gitlab.com/project/api
* [new ref] refs/pipelines/145924346 -> refs/pipelines/145924346
* [new branch] staging -> origin/staging
* [new branch] master -> origin/master
* [new tag] v0.1.0 -> v0.1.0
* [new tag] v0.1.1 -> v0.1.1
Checking out 94248497 as staging...
Skipping Git submodules setup
Restoring cache
00:04
Checking cache for default...
Downloading cache.zip from https://storage.googleapis.com/gitlab-com-runners-cache/project/8257525/default
Successfully extracted cache
Downloading artifacts
00:02
Running before_script and script
When the pipeline runs for production deploy, tagging a commit in the branch staging
, it gets the correct files
Running with gitlab-runner 12.10.0-rc2 (6c8c540f)
on docker-auto-scale 72989761
Preparing the "docker+machine" executor
00:12
Using Docker executor with image php:7.2-fpm-alpine ...
Pulling docker image php:7.2-fpm-alpine ...
Using docker image sha256:515e9a15eafb1661d0045a653947c79fe22024ab20abc23276dd901916e3ef57 for php:7.2-fpm-alpine ...
Preparing environment
00:04
Running on runner-72989761-project-8257525-concurrent-0 via runner-72989761-srm-1589352412-cee1ac10...
Getting source from Git repository
00:02
$ eval "$CI_PRE_CLONE_SCRIPT"
Fetching changes...
Initialized empty Git repository in /builds/project/api/.git/
Created fresh repository.
From https://gitlab.com/project/api
* [new ref] refs/pipelines/145444606 -> refs/pipelines/145444606
* [new branch] staging -> origin/staging
* [new branch] master -> origin/master
* [new tag] v0.1.0 -> v0.1.0
* [new tag] v0.1.1 -> v0.1.1
* [new tag] v0.1.2 -> v0.1.2
Checking out aa962a18 as v0.1.2...
Skipping Git submodules setup
Restoring cache
00:04
Checking cache for default...
Downloading cache.zip from https://storage.googleapis.com/gitlab-com-runners-cache/project/8257525/default
Successfully extracted cache
Downloading artifacts
00:01
Running before_script and script
There is something wrong with my CI configuration?
Deployer uses the files in current branch, so if the Runner checks out to a branch it will deploy current branch files. It works only with tags
Edited by Gabriele