-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
52 lines (49 loc) · 1.44 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
image: node:20
stages:
- mirror-from-external
- deploy
mirror-from-external:
stage: mirror-from-external
image: ubuntu:18.04
before_script:
- apt-get update -y && apt-get install openssh-client -y
- apt install git -y
- eval $(ssh-agent -s)
- echo "$GIT_SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan $GITLAB_HOST >> ~/.ssh/known_hosts 2>/dev/null
- ssh-keyscan $GITHUB_HOST >> ~/.ssh/known_hosts 2>/dev/null
- chmod 644 ~/.ssh/known_hosts
- git config --global user.name "${GIT_USER_NAME}"
- git config --global user.email "${GIT_USER_EMAIL}"
- ssh -T git@$GITLAB_HOST 2>&1 | grep "successful" || true # Test SSH connection
script:
- if [ -z "$DESTINATION_REPOSITORY" ]; then echo "DESTINATION_REPOSITORY is not set"; exit 1; fi
- echo $SOURCE_REPOSITORY
- git clone --mirror $SOURCE_REPOSITORY $DESTINATION_DIR
- cd $DESTINATION_DIR
- git remote remove origin
- git remote add origin "$DESTINATION_REPOSITORY"
- git push --prune --all
- git push --prune --tags
only:
- branches
pages:
stage: deploy
cache:
key:
files:
- package-lock.json
prefix: npm
paths:
- node_modules/
script:
- npm install --omit=dev
- npm run build --repository=$CI_PROJECT_NAME
- cp -a dist/. public/
artifacts:
paths:
- public
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH