-
Notifications
You must be signed in to change notification settings - Fork 11
240 lines (234 loc) · 7.14 KB
/
files-sync.yml
File metadata and controls
240 lines (234 loc) · 7.14 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
name: Files sync
on:
workflow_dispatch:
inputs:
project_slug:
description: 'Project slug without the micronaut- prefix. Leave empty to sync every project.'
required: false
type: string
schedule:
- cron: '0 5 * * *'
jobs:
prepare-matrix:
if: github.repository == 'micronaut-projects/micronaut-project-template'
runs-on: ubuntu-latest
outputs:
repos: ${{ steps.prepare.outputs.repos }}
steps:
- name: Prepare repository matrix
id: prepare
shell: bash
run: |
repos=(
acme
aot
avro
aws
azure
build-plugin-sourcegen
cache
cassandra
chatbots
coherence
control-panel
core
crac
data
discovery-client
eclipsestore
elasticsearch
email
flyway
fuzzing
gcp
graphql
groovy
graal-languages
grpc
guice
hibernate-validator
jackson-xml
jaxrs
jms
jmx
json-schema
kafka
kotlin
kubernetes
langchain4j
liquibase
logging
mcp
micrometer
mongodb
mqtt
multitenancy
nats
neo4j
object-storage
openapi
openrewrite
opensearch
oracle-cloud
picocli
platform
problem-json
projectgen
pulsar
r2dbc
rabbitmq
reactor
redis
rss
rxjava3
security
serialization
servlet
session
sourcegen
spring
sql
test
test-resources
toml
tracing
validation
views
)
slug="${{ github.event.inputs.project_slug }}"
if [ -n "${slug}" ]; then
for repo in "${repos[@]}"; do
if [ "${repo}" = "${slug}" ]; then
printf 'repos=["%s"]\n' "${slug}" >> "${GITHUB_OUTPUT}"
exit 0
fi
done
echo "Unknown project slug: ${slug}" >&2
exit 1
fi
json="["
for repo in "${repos[@]}"; do
if [ "${json}" != "[" ]; then
json+=","
fi
json+="\"${repo}\""
done
json+="]"
echo "repos=${json}" >> "${GITHUB_OUTPUT}"
sync-files:
needs: prepare-matrix
if: github.repository == 'micronaut-projects/micronaut-project-template'
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 3
matrix:
repo: ${{ fromJson(needs.prepare-matrix.outputs.repos) }}
steps:
- name: Checkout source
uses: actions/checkout@v6
with:
path: source
- name: Checkout target - default branch
uses: actions/checkout@v6
with:
repository: micronaut-projects/micronaut-${{ matrix.repo }}
path: target
fetch-depth: 0
token: ${{ secrets.GH_TOKEN }}
- name: Determine current branch
id: branch
working-directory: target
run: |
branch=$(git rev-parse --abbrev-ref HEAD)
echo "Current branch: ${branch}"
echo "branch=${branch}" >> $GITHUB_OUTPUT
- name: Sync workflows
run: |
mkdir -p target/.github/workflows/
rsync --verbose --verbose --archive -F "source/.github/workflows/" "target/.github/workflows/"
rm -f target/.github/dependabot.yml
rm -f target/.github/stale.yml
rm -f target/.github/release-drafter.yml
rm -f target/.github/workflows/release-notes.yml
rm -f target/.github/workflows/dependency-update.yml
rm -f target/.github/workflows/sonarqube.yml
- name: Copy files from source to target branches
run: |
while IFS= read -r file; do
dest_dirname="$(dirname $file)"
dest_filename="$(basename $file)"
mkdir -p target/$dest_dirname
[ ! -f target/${dest_dirname}/${dest_filename}.lock ] && cp source/$file target/${dest_dirname}/${dest_filename}
done <<< "$FILES"
env:
FILES: |-
.clineignore
.editorconfig
.gitattributes
.gitignore
.github/renovate.json
.github/release.yml
.github/ISSUE_TEMPLATE/bug_report.yaml
.github/ISSUE_TEMPLATE/config.yml
.github/ISSUE_TEMPLATE/new_feature.yaml
.github/ISSUE_TEMPLATE/other.yaml
.sdkmanrc
gradle/wrapper/gradle-wrapper.jar
gradle/wrapper/gradle-wrapper.properties
gradlew
gradlew.bat
MAINTAINING.md
SECURITY.md
LICENSE
config/HEADER
config/spotless.license.java
config/checkstyle/checkstyle.xml
config/checkstyle/suppressions.xml
- name: Copy all skills from source to target branches
run: |
rsync_args=(-a --delete --exclude='*.lock')
if [ -d "target/.agents/skills" ]; then
while IFS= read -r -d '' lock_file; do
skill_file="${lock_file%.lock}"
rel="${skill_file#target/.agents/skills/}"
rsync_args+=(--exclude="$rel")
done < <(find "target/.agents/skills" -name "*.lock" -print0)
fi
mkdir -p target/.agents/skills
rsync "${rsync_args[@]}" source/.agents/skills/ target/.agents/skills/
- name: Sleep for 3 minutes to avoid rate limiting
run: sleep 180s
shell: bash
- name: Create Pull Request - ${{ steps.branch.outputs.branch }}
uses: peter-evans/create-pull-request@v8
with:
path: target
token: ${{ secrets.GH_TOKEN }}
committer: micronaut-build <${{ secrets.MICRONAUT_BUILD_EMAIL }}>
author: micronaut-build <${{ secrets.MICRONAUT_BUILD_EMAIL }}>
commit-message: Update common files
title: "[${{ matrix.repo }}] Update common files for branch ${{ steps.branch.outputs.branch }}"
body: Update common files
labels: "relates-to: build"
branch: sync-files-${{ steps.branch.outputs.branch }}
base: ${{ steps.branch.outputs.branch }}
add-paths: |
.clineignore
.editorconfig
.gitattributes
.gitignore
.agents/skills
.github/*
.github/ISSUE_TEMPLATE/*
.github/workflows/*
.sdkmanrc
gradle/*
gradlew*
MAINTAINING.md
SECURITY.md
LICENSE
config/HEADER
config/spotless.license.java
config/checkstyle/checkstyle.xml
config/checkstyle/suppressions.xml