feat(git_push_mirror): Added a job that syncs to a remote git repo
User must construct url with userdetails for the sync to work in non-public writable repositories Changes to be committed: new file: git_push_mirror/.gitlab-ci.yml new file: git_push_mirror/README.md issue #1
This commit is contained in:
22
git_push_mirror/.gitlab-ci.yml
Normal file
22
git_push_mirror/.gitlab-ci.yml
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
.git_push_mirror:
|
||||
image: alpine:latest
|
||||
stage: sync
|
||||
before_script:
|
||||
- apk update
|
||||
- apk add git
|
||||
script:
|
||||
- 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: '$CI_COMMIT_BRANCH == "master"'
|
||||
- if: '$CI_COMMIT_BRANCH == "development"'
|
||||
when: always
|
||||
|
||||
|
||||
|
45
git_push_mirror/README.md
Normal file
45
git_push_mirror/README.md
Normal file
@ -0,0 +1,45 @@
|
||||
# git push mirror Admin Manual Manual
|
||||
This job does a git push to a remote git repo.
|
||||
|
||||
This job provides the following badge:
|
||||
|
||||
- None
|
||||
|
||||
## Dependencies
|
||||
|
||||
- None
|
||||
|
||||
## your .gitlab-ci.yml changes
|
||||
To use this job add the following to your `.gitlab-ci.yml` file
|
||||
|
||||
``` yaml
|
||||
stages:
|
||||
- sync
|
||||
|
||||
include:
|
||||
- remote: https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/raw/development/git_push_mirror/.gitlab-ci.yml
|
||||
|
||||
Github (Push --mirror):
|
||||
variables:
|
||||
GIT_SYNC_URL: "https://$GITHUB_USERNAME_ROBOT:$GITHUB_TOKEN_ROBOT@github.com/NoFussComputing/gitlab-ci.git"
|
||||
extends:
|
||||
- .git_push_mirror
|
||||
|
||||
```
|
||||
|
||||
## CI/CD Variables required
|
||||
|
||||
| var name | Description |
|
||||
|:----:|:----|
|
||||
| GIT_SYNC_URL | this is the remote git repositories https clone address. <br>***Note:** if the remote repository requires authentication, you will need to build the url. like above.* |
|
||||
|
||||
|
||||
## Job Workflow
|
||||
|
||||
|
||||
## Artifacts
|
||||
|
||||
-
|
||||
|
||||
## License
|
||||
To view the license for this folder and any sub-folders, refer [here](https://gitlab.com/nofusscomputing/projects/gitlab-ci)
|
Reference in New Issue
Block a user