forked from k8scat/action-mirror-git
-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (47 loc) · 1.74 KB
/
github-to-github.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
name: GitHub to GitHub
on:
workflow_dispatch:
schedule:
- cron: "0 2 * * 3"
jobs:
mirror:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Login Source GitHub
run: |
gh --version
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
gh auth status
- name: List repos
id: list_repos
run: |
repo_list=$(gh repo list k8scat -L 1000 --json name -t '{{range $i, $n := .}}{{if (gt $i 0)}},{{end}}{{$n.name}}{{end}}')
echo "::set-output name=repo_list::${repo_list}"
- name: GitHub to GitHub
uses: k8scat/[email protected]
with:
source_protocol: https
source_host: github.com
source_username: k8scat
source_token: ${{ secrets.GITHUB_TOKEN }}
dest_protocol: https
dest_host: github.com
dest_username: k8scat-archived
dest_token: ${{ secrets.DEST_TOKEN_GITHUB }}
dest_token_username: gitobor
mirror_repos: ${{ steps.list_repos.outputs.repo_list }}
dest_create_repo_script: |
if ! gh auth status; then
echo "${INPUT_DEST_TOKEN}" | gh auth login --with-token
gh auth status
fi
found=$(gh repo list ${INPUT_DEST_USERNAME} -L 1000 --json name -t "{{range .}}{{if (eq .name \"${REPO_NAME}\")}}{{.name}}{{end}}{{end}}")
if [[ -n "${found}" ]]; then
echo "Repo already exists: ${REPO_NAME}"
exit 0
fi
gh repo create "${INPUT_DEST_USERNAME}/${REPO_NAME}" --private
lark_webhook: ${{ secrets.LARK_WEBHOOK }}
notify_prefix: "GitHub to GitHub"
ignore_error: "true"