1
- name : sync-git-gui -branches
1
+ name : sync-upstream -branches
2
2
3
3
on :
4
4
schedule :
5
5
- cron : ' 31 22 * * *'
6
6
workflow_dispatch :
7
7
8
- env :
9
- SOURCE_REPOSITORY : j6t/git-gui
10
- TARGET_REPOSITORY : gitgitgadget/git
11
- TARGET_REF_NAMESPACE : git-gui/
12
-
13
8
# We want to limit queuing to a single workflow run i.e. if there is already
14
9
# an active workflow run and a queued one, queue another one canceling the
15
10
# already queued one.
16
11
concurrency :
17
12
group : ${{ github.workflow }}
18
13
19
14
jobs :
20
- sync-git-gui -branches :
15
+ sync-upstream -branches :
21
16
runs-on : ubuntu-latest
17
+ strategy :
18
+ matrix :
19
+ spec :
20
+ - source-repo : j6t/git-gui
21
+ target-repo : gitgitgadget/git
22
+ target-ref-namespace : git-gui/
23
+
22
24
steps :
23
25
- name : check which refs need to be synchronized
24
26
uses : actions/github-script@v7
25
27
id : check
26
28
with :
27
29
script : |
28
- const [targetRepoOwner, targetRepoName] = process.env.TARGET_REPOSITORY.split('/')
30
+ const sourceRepo = ${{ toJSON(matrix.spec.source-repo) }}
31
+ const targetRepo = ${{ toJSON(matrix.spec.target-repo) }}
32
+ const targetRefNamespace = ${{ toJSON(matrix.spec.target-ref-namespace) }}
33
+
34
+ const [targetRepoOwner, targetRepoName] = targetRepo.split('/')
29
35
core.setOutput('target-repo-owner', targetRepoOwner)
30
36
core.setOutput('target-repo-name', targetRepoName)
31
37
@@ -72,10 +78,10 @@ jobs:
72
78
}
73
79
}
74
80
75
- const sourceRefs = await getRefs(process.env.SOURCE_REPOSITORY )
76
- const targetRefs = await getRefs(process.env.TARGET_REPOSITORY, process.env.TARGET_REF_NAMESPACE )
81
+ const sourceRefs = await getRefs(sourceRepo )
82
+ const targetRefs = await getRefs(targetRepo, targetRefNamespace )
77
83
78
- const targetPrefix = `refs/heads/${process.env.TARGET_REF_NAMESPACE}`
84
+ const targetPrefix = targetRefNamespace ? `refs/heads/${targetRefNamespace}` : 'refs/heads/'
79
85
80
86
const refspecs = []
81
87
const toFetch = new Set()
@@ -138,7 +144,7 @@ jobs:
138
144
set -ex
139
145
git init --bare
140
146
141
- git remote add source " ${{ github.server_url }}/$SOURCE_REPOSITORY"
147
+ git remote add source ' ${{ github.server_url }}/${{ matrix.spec.source-repo }}'
142
148
# pretend to be a partial clone
143
149
git config remote.source.promisor true
144
150
git config remote.source.partialCloneFilter blob:none
@@ -151,4 +157,4 @@ jobs:
151
157
# push the commits
152
158
printf '%s' '${{ steps.check.outputs.refspec }}' |
153
159
xargs -d ' ' -r git -c http.extraHeader='${{ steps.auth.outputs.header }}' \
154
- push " ${{ github.server_url }}/$TARGET_REPOSITORY"
160
+ push ' ${{ github.server_url }}/${{ matrix.spec.target-repo }}'
0 commit comments