-
Notifications
You must be signed in to change notification settings - Fork 46
52 lines (48 loc) · 2.04 KB
/
backup-to-gitlab.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
name: backup to gitlab
on: [push]
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
backup-to-gitlab:
if: github.repository_owner == 'linuxdeepin'
name: backup-to-gitlab
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
repository: "linuxdeepin/jenkins-bridge-client"
path: jenkins-bridge-client
- name: Install Client
run: |
cd $GITHUB_WORKSPACE/jenkins-bridge-client
go build .
sudo install -Dvm755 jenkins-bridge-client -t /usr/bin/
- name: Trigger sync
id: generate-runid
run: |
echo "::set-output name=RUN_ID::$(jenkins-bridge-client -triggerSync -token '${{ secrets.BRIDGETOKEN }}')"
- name: Print log
run: |
jenkins-bridge-client -printlog -token "${{ secrets.BRIDGETOKEN }}" -runid "${{ steps.generate-runid.outputs.RUN_ID }}"
backup-to-gitee:
if: github.repository_owner == 'linuxdeepin'
runs-on: ubuntu-latest
steps:
- name: create-repo
run: |
repo=${{ github.event.repository.name }}
homepage="https://github.com/linuxdeepin/${repo}"
description="mirror of ${homepage}"
# remove '.' prefix
repo=${repo#"."}
curl -X POST --header 'Content-Type: application/json;charset=UTF-8' 'https://gitee.com/api/v5/enterprises/linuxdeepin/repos' -d '{"private": 1,"access_token":"${{ secrets.GITEE_SYNC_TOKEN }}","name":"'"$repo"'","description":"'"$description"'","homepage":"'"$homepage"'","has_issues":"false","has_wiki":"false","can_comment":"false"}' || true
- name: push
run: |
git clone --bare https://github.com/linuxdeepin/${{ github.event.repository.name }}.git .git
repo=${{ github.event.repository.name }}
# remove '.' prefix
repo=${repo#"."}
git remote set-url origin https://myml:${{ secrets.GITEE_SYNC_TOKEN }}@gitee.com/linuxdeepin/${repo}.git
git push -f --all --prune origin
git push --tags origin