Files
gitlab-ci/git_push_mirror/.gitlab-ci.yml
Jon 04e7e928e0 feat(ci_rules): add exists and changes for rules
now defined jobs check for existance of file and for changes
to launch a job

!41 #32
2023-06-02 15:26:35 +09:30

33 lines
1022 B
YAML

.git_push_mirror:
image: alpine:latest
stage: sync
before_script:
- apk update
- apk add git
script:
- if [ "0$GIT_SYNC_URL" == "0"]; then echo "[ERROR] you must define variable GIT_SYNC_URL for mirroring this repository."; fi
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/$CI_PROJECT_PATH --mirror $CI_PROJECT_NAME
- cd $CI_PROJECT_NAME
- git remote add destination $GIT_SYNC_URL
- echo "https://gitlab.com/ $CI_PROJECT_PATH / $CI_PROJECT_NAME .git"
- git push destination --mirror
artifacts:
expire_in: 1 day
rules:
- if: '$JOB_STOP_GIT_PUSH_MIRROR'
when: never
- if: $GIT_SYNC_URL == null
when: never
- if: # condition_master_or_dev_push
(
$CI_COMMIT_BRANCH == "master" ||
$CI_COMMIT_BRANCH == "development"
) &&
$CI_PIPELINE_SOURCE == "push"
when: always
- when: never