ci: utilize Gitlab's mirroring

- https://docs.gitlab.com/ee/user/project/repository/repository_mirroring.html
- Commits to protected branches are push to mirror within a minute
- Less one private key to manage
This commit is contained in:
MDLeom 2020-07-12 08:41:20 +01:00
parent 200c2fdcca
commit 19e17e1193
No known key found for this signature in database
GPG Key ID: 5D9DB57A25D34EE3
1 changed files with 1 additions and 21 deletions

View File

@ -9,7 +9,6 @@ variables:
test:
before_script:
- 'which ssh-agent || (apk update && apk add openssh-client git)'
- npm install -g pnpm
- pnpm install
@ -17,24 +16,6 @@ test:
- pnpm install snyk && pnpm run snyk # Refer to "scripts" in package.json
- pnpm run hexo
# Update github mirror
after_script:
# Import SSH key
- eval $(ssh-agent -s)
- echo "$GH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
# (workaround) force exit code 0
- ssh -T git@github.com || ":"
- git remote add mirror git@github.com:curbengh/blog.git
# Discard changes before checking out branch
- git reset HEAD --hard
- git checkout master && git push mirror master
- git checkout site && git push mirror site
rules:
# Skip in renovate job
- if: '$RENOVATE == "true"'
@ -48,8 +29,7 @@ test:
renovate: # Check dependency update
before_script:
- apk update
- apk add git
- apk update && apk add git
- npm install
script: