-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yml
executable file
·139 lines (129 loc) · 3.88 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# docker image from https://github.com/DavidAnson/markdownlint-cli2
# vscode markdownlint https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint
# markdownlint-cli2: https://github.com/DavidAnson/markdownlint-cli2
# markdownlint rules: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md
# markdown-link-check: https://github.com/tcort/markdown-link-check
#
variables:
GITLAB_REPO: [email protected]:maix_sw/k230_canmv_docs.git
GITHUB_REPO: [email protected]:kendryte/k230_canmv_docs.git
GITEE_REPO: [email protected]:kendryte/k230_canmv_docs.git
default:
interruptible: true
# MR merged
merge_sync:
rules:
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "main"
extends:
- .setup_env
- .sync_github_gitee
# tag push
tag_sync:
rules:
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_TAG =~ /^v\d+\.\d+.*$/
extends:
- .setup_env
- .sync_github_gitee
# auto sync
schedule_sync:
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
extends:
- .setup_env
- .sync_github_gitee
# manual sync
manual_sync:
rules:
- if: '$CI_PIPELINE_SOURCE == "web"'
when: always
extends:
- .setup_env
- .sync_github_gitee
# new MR open
markdown-link-check:
rules:
# MR job
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
stage: test
timeout: 10m
tags:
- k230
image: ai.b-bug.org:5000/markdown:latest
script:
- uname -a
- whoami
- pwd
- find . -name \*.md -print0 | xargs -0 -n1 markdown-link-check -q
# new MR open
markdownlint:
rules:
# MR job
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
stage: test
timeout: 10m
image: ai.b-bug.org:5000/markdown:latest
tags:
- k230
script:
- uname -a
- whoami
- pwd
#- markdownlint-cli2 *.md **/*.md **/**/*.md **/**/**/*.md **/**/**/**/*.md
- find . -name \*.md -print0 | xargs -0 markdownlint-cli2
.setup_env:
before_script:
- echo '----------Build ENV Prepare----------'
- echo 'Add SSH KEY for Multiple repo'
- "which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )"
- eval $(ssh-agent -s)
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_PRIVATE_KEY" | ssh-add - > ~/.ssh/id_ed25519 || exit 1
- '[[ -f /.dockerenv ]] && echo -e "Host *\n StrictHostKeyChecking no\n" > ~/.ssh/config'
- echo $SHELL
- echo "increate ssh timeout for github"
- echo " ServerAliveInterval 30" >> ~/.ssh/config
- echo " ServerAliveCountMax 60" >> ~/.ssh/config
- echo " TCPKeepAlive yes" >> ~/.ssh/config
- cat ~/.ssh/config
- whoami
- uptime
- pwd
- uname -a
- cat /etc/issue
- echo $CI_PROJECT_DIR
- echo $CI_PROJECT_NAME
- echo '----------set git config ----------'
- echo "${GITLAB_USER_EMAIL}"
- echo "${GITLAB_USER_NAME}"
- git config --global user.email "${GITLAB_USER_EMAIL}"
- git config --global user.name "${GITLAB_USER_NAME}"
- git config --global --add safe.directory $CI_PROJECT_DIR
.sync_github_gitee:
timeout: 45m
image: ai.b-bug.org:5000/k230_sdk:latest
tags:
- k230_sdk
script:
- cd $CI_PROJECT_DIR
- ls -alht
- rm -rf ./k230_canmv_docs/
- git clone ${GITLAB_REPO} k230_canmv_docs || exit 1
- cd k230_canmv_docs || exit 1
- pwd
- git checkout main
- git branch -a
- git status
- echo '---pull latest main branch---'
- git pull origin main
- echo '---fetch all tags---'
- git fetch --tags
- git remote add github ${GITHUB_REPO}
- git remote add gitee ${GITEE_REPO}
- git remote -v
- git branch -a
- git status
- echo "---push to gitee---"
- git push --atomic --tags -u -f gitee main || git push --atomic --tags -u -f gitee main
- echo "---push to github---"
- git push --atomic --tags -u -f github main || git push --atomic --tags -u -f github main || git push --atomic --tags -u -f github main