In my project I use merge requests to test builds, and deploy once the commit is merged to master. Currently my .gitlab-ci.yml
looks like:
build:
stage: build
script:
- yarn build
artifacts:
paths:
- public
deploy:
stage: deploy
script: yarn deploy
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
This way only commits that build succesfully get merged to master and deployed. However the build stage runs twice, once in the merge request branch and once in master. I would like to have something like:
build:
stage: build
script:
- yarn build
artifacts:
paths:
- public
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
deploy:
stage: deploy
script: yarn deploy
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
but the deploy job should have a way to pull the artifact generated by the build
job in the merge request branch. Is it possible?