-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (117 loc) · 4.02 KB
/
git-mirrors.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
name: "Git Mirrors"
on:
# TODO: `on: push` is only for quick debugging
push:
branches:
- master
paths:
- ".github/actions/git-mirror/index.js"
- ".github/workflows/git-mirrors.yml"
schedule:
- cron: '44 * * * *'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}
jobs:
'mirror':
# continue-on-error: true
strategy:
max-parallel: 3
fail-fast: false
matrix:
'json':
- |
{
"name": "beautifulsoup"
}
- |
{
"name": "miredo"
}
- |
{
"name": "turnip"
}
- |
{
"name": "launchpad"
}
- |
{
"name": "inkscape"
}
- |
{
"name": "mkvtoolnix"
}
- |
{
"name": "graphviz"
}
# - |
# {
# "name": "ctx"
# }
# contains `pull` refs which GitHub refuses to accept, needs to wait for refs whitelist/blacklist feature
# - |
# {
# "name": "libre-menu-editor"
# }
- |
{
"name": "blackbox"
}
name: "🪞 Mirror `${{ fromJSON(matrix['json'])['name'] }}`"
environment:
name: "${{ format('mirror--{0}', fromJSON(matrix['json'])['name']) }}"
url: >
${{ format('https://github.com/{0}/{1}',
github.repository_owner,
fromJSON(matrix['json'])['name']
)}}
runs-on: 'ubuntu-latest'
steps:
- name: "Verify Remote Git Refs Equality"
id: 'verify-refs'
uses: 'actions-rindeal/git-remote-ref-compare@master'
with:
'source-repo-url': ${{ vars['SOURCE_REPO_URL'] }}
# TODO: refactor the repo/url processing from the action's index.js into a separate step and then use its outputs here and in the mirroring action
'target-repo-url': https://github.com/facsimiles/${{ vars['TARGET_GITHUB_REPO'] || fromJSON(matrix['json'])['name'] }}.git
env:
'RUNNER_DEBUG': '1'
- name: "📥 Checkout ${{ github.repository }}"
if: ${{ steps['verify-refs'].outputs['refs-differ'] == 'true' }}
uses: 'actions/checkout@main'
- name: "🔑 Create GitHub App Token"
if: ${{ steps['verify-refs'].outputs['refs-differ'] == 'true' }}
uses: 'actions/create-github-app-token@v1'
id: 'app-token'
with:
'app-id': ${{ vars['PUSH_APP_ID'] }}
'private-key': ${{ secrets['PUSH_APP_PRIVATE_KEY'] }}
'owner': ${{ github.repository_owner }}
'repositories': "${{ fromJSON(matrix['json'])['name'] }}"
- name: "🆔 Set GitHub App/Bot 🤖 as Git User 👤"
if: ${{ steps['verify-refs'].outputs['refs-differ'] == 'true' }}
uses: 'actions-rindeal/git-identity-from-username@v2'
with:
'username': ${{ format('{0}[bot]', steps['app-token'].outputs['app-slug']) }}
'failover-name': 'facsimiles-push[bot]'
'failover-email': '180179525+facsimiles-push[bot]@users.noreply.github.com'
- name: "🔄 Mirror Repository"
if: ${{ steps['verify-refs'].outputs['refs-differ'] == 'true' }}
id: 'mirror'
uses: './.github/actions/git-mirror'
with:
'source-repo-url': ${{ vars['SOURCE_REPO_URL'] }}
'target-github-repo': ${{ vars['TARGET_GITHUB_REPO'] || fromJSON(matrix['json'])['name'] }}
'target-ssh-key': ${{ secrets['TARGET_SSH_KEY'] }}
'target-token': ${{ secrets['TARGET_TOKEN'] || steps['app-token'].outputs['token'] }}
- name: "📝 Log Mirroring Step Metadata"
if: ${{ steps['verify-refs'].outputs['refs-differ'] == 'true' && always() }}
shell: bash
run: |
echo "${MIRROR_STEP_JSON}" | jq -C .
env:
MIRROR_STEP_JSON: ${{ toJSON(steps['mirror']) }}