-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (92 loc) · 3.3 KB
/
git-sync.yml
File metadata and controls
110 lines (92 loc) · 3.3 KB
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
# Copyright (c) 2025-2026 TiaC Systems
# SPDX-License-Identifier: MIT
name: Git Sync
# Reusing the special GitHub action 'git-sync' inside of a pre-defined
# and static execution matrix, read from a YAML notated file given by
# the required input parameter 'matrix' with following expected content:
#
# to: list of destination organisations, either as public git+https or
# protected (private) git+ssh base URI; multiple entries allowed
#
# from: list of only one single source organisation from where to sync
#
# repo: list of multiple repository that have to exist on both, source
# and destination organisations
#
# refspec: list of multiple Git refspecs that have to sync on all Git repos
# https://docs.github.com/en/actions/sharing-automations/reusing-workflows
on:
workflow_call:
inputs:
matrix:
description: "YAML file with matrix axises."
required: true
type: string
from-repo-prefix:
description: "Prefix to all source repository names."
required: false
default: ""
type: string
from-repo-suffix:
description: "Suffix to all source repository names."
required: false
default: ""
type: string
to-repo-prefix:
description: "Prefix to all destination repository names."
required: false
default: ""
type: string
to-repo-suffix:
description: "Suffix to all destination repository names."
required: false
default: ""
type: string
secret-prefix:
description: "Construct the secret variable name with that prefix."
required: false
default: ""
type: string
secret-suffix:
description: "Construct the secret variable name with that suffix."
required: false
default: ""
type: string
run-name: Git Sync
jobs:
setup:
name: Setup
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-git-sync-matrix.outputs.matrix }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Load matrix data
id: set-git-sync-matrix
run: |
echo "matrix=$(yq -o json '. ' ${{ inputs.matrix }} | jq -c .)" >> $GITHUB_OUTPUT
execute:
name: Execute
runs-on: ubuntu-latest
needs:
- setup
strategy:
fail-fast: true
matrix: ${{ fromJson(needs.setup.outputs.matrix) }}
steps:
- name: Generate Secret String
run: |
varname_prefix="${{ inputs.secret-prefix }}"
varname_unique="$(echo '${{ matrix.repo }}' | tr '[:punct:]' '_' | tr '[:lower:]' '[:upper:]')"
varname_suffix="${{ inputs.secret-suffix }}"
varname="${varname_prefix}${varname_unique}${varname_suffix}"
echo "SECRET_STRING=${varname}" >> $GITHUB_ENV
- name: Sync Git Refspecs
uses: tiacsys/git-sync@v3
with:
source_repo: "${{ matrix.from }}/${{ inputs.from-repo-prefix }}${{ matrix.repo }}${{ inputs.from-repo-suffix }}.git"
source_branch: "${{ matrix.refspec }}"
destination_repo: "${{ matrix.to }}/${{ inputs.to-repo-prefix }}${{ matrix.repo }}${{ inputs.to-repo-suffix }}.git"
destination_branch: "${{ matrix.refspec }}"
ssh_private_key: "${{ secrets[env.SECRET_STRING] }}"