Skip to content

Commit 4a7eeaa

Browse files
committed
.github: sync_ci.yml: Add workflow to syncronize workflows
Adds a sync_ci.yml that syncronizes the ci files to other branches. Is added only to .github/workflows/cron.yml and not to .github/workflows.mirror/cron.yml because it is assumed that the branches pushed the ci to are mirror under the mirror repository, not requiring to patch the ci again, instead, just mirror using the mirror.yml like the main branch. Signed-off-by: Jorge Marques <[email protected]>
1 parent d65ab73 commit 4a7eeaa

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

.github/workflows/cron.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,16 @@ jobs:
2828
fetch_url: "https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git"
2929
branch: "testing"
3030

31+
self-branches:
32+
uses: ./.github/workflows/sync_ci.yml
33+
secrets: inherit
34+
permissions:
35+
contents: write
36+
actions: write
37+
strategy:
38+
matrix:
39+
branch:
40+
- "oran-6.12.38-y"
41+
- "adsp-6.12.38-y"
42+
with:
43+
branch: ${{ matrix.branch }}

.github/workflows/sync_ci.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: CI synchronization
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
branch:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
mirror:
12+
runs-on: [self-hosted, v1]
13+
14+
steps:
15+
- uses: analogdevicesinc/doctools/checkout@v1
16+
17+
- name: increase-limits
18+
run: |
19+
git config http.postBuffer 157286400
20+
21+
- name: update-mirror
22+
run: |
23+
git switch -d
24+
git remote prune origin
25+
git fetch origin ${{ inputs.branch }}:${{ inputs.branch }} -f
26+
git switch ${{ inputs.branch }}
27+
28+
git fetch origin main --depth=1
29+
declare -a arr=(
30+
"ci"
31+
".github"
32+
"arch/arm/configs/adi_ci_defconfig"
33+
"arch/arm64/configs/adi_ci_defconfig"
34+
"arch/x86/configs/adi_ci_defconfig"
35+
)
36+
for i in "${arr[@]}"
37+
do
38+
git rm -rf "$i" || true
39+
git checkout origin/main -- "$i"
40+
done
41+
commit=$(git rev-parse origin/main)
42+
git commit -m "deploy: $commit" -m "patch ci" -s
43+
echo "{{ inputs.branch }}=${{ inputs.branch }}" >> "$GITHUB_ENV"
44+
45+
- name: push-ci
46+
env:
47+
WORKFLOW_SECRET: ${{ secrets.WORKFLOW_SECRET}}
48+
if: ${{ env.WORKFLOW_SECRET != '' }}
49+
run: |
50+
url_=$(git remote get-url origin)
51+
url="https://x-access-token:${{ secrets.WORKFLOW_SECRET }}@github.com/${{ github.repository }}.git"
52+
git remote set-url origin "$url"
53+
git push origin ${{ inputs.branch }}:${{ inputs.branch }} -f || true
54+
git remote set-url origin "$url_"
55+
56+
- name: push-ci
57+
env:
58+
WORKFLOW_SECRET: ${{ secrets.WORKFLOW_SECRET}}
59+
if: ${{ env.WORKFLOW_SECRET == '' }}
60+
run: |
61+
git push origin ${{ inputs.branch }}:${{ inputs.branch }} -f
62+
63+
- name: unset-limits
64+
run: |
65+
git config --unset http.postBuffer
66+
67+
- name: clean-up
68+
if: github.event_name == 'schedule'
69+
run: |
70+
git gc --prune=now
71+
72+
- name: log-cached-branches
73+
run: |
74+
git --no-pager branch | cut -c 3- | \
75+
while IFS= read -r b; do printf "$b: " ; git rev-list --count $b; done

0 commit comments

Comments
 (0)