-
Notifications
You must be signed in to change notification settings - Fork 1
50 lines (44 loc) · 1.45 KB
/
Copy pathsync-readmes.yml
File metadata and controls
50 lines (44 loc) · 1.45 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
name: Sync shared files across branches
on:
push:
branches:
- dev
paths:
- README.md
- README_FR.md
- versions.json
- compile-all.sh
- .github/workflows/**
jobs:
sync:
if: ${{ !contains(github.event.head_commit.message, '[skip sync]') }}
runs-on: ubuntu-latest
steps:
- name: Checkout source branch
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Sync shared files to all branches
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
SOURCE_BRANCH="${GITHUB_REF#refs/heads/}"
TARGETS=("main")
SHARED_FILES=("README.md" "README_FR.md" "versions.json" "compile-all.sh" ".github/workflows/")
for target in "${TARGETS[@]}"; do
if [ "$target" = "$SOURCE_BRANCH" ]; then
continue
fi
if git show-ref --verify --quiet refs/remotes/origin/"$target"; then
git checkout "$target"
git checkout "$SOURCE_BRANCH" -- "${SHARED_FILES[@]}"
if ! git diff --cached --quiet; then
git commit -m "chore: sync shared files from $SOURCE_BRANCH [skip sync]"
git push origin "$target"
fi
fi
done