Skip to content

Commit 2a71b7f

Browse files
authored
Merge pull request #18 from LibreCodeCoop/feat/consumer-workflow-sync
feat: automate consumer workflow synchronization
2 parents 4cf7b0f + acc4ee0 commit 2a71b7f

5 files changed

Lines changed: 651 additions & 0 deletions

File tree

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
2+
# SPDX-License-Identifier: AGPL-3.0-or-later
3+
4+
name: Sync consumer workflows
5+
6+
on:
7+
workflow_dispatch:
8+
push:
9+
branches:
10+
- main
11+
paths:
12+
- 'workflow-templates/**'
13+
- 'consumers.json'
14+
- 'scripts/sync_consumer.py'
15+
- '.github/workflows/sync-consumers.yml'
16+
schedule:
17+
- cron: '41 4 * * 0'
18+
19+
permissions:
20+
contents: read
21+
22+
jobs:
23+
consumers:
24+
name: Build consumer matrix
25+
runs-on: ubuntu-latest
26+
outputs:
27+
matrix: ${{ steps.matrix.outputs.matrix }}
28+
steps:
29+
- name: Checkout workflow source
30+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
31+
with:
32+
persist-credentials: false
33+
34+
- name: Build matrix
35+
id: matrix
36+
run: echo "matrix=$(python3 scripts/sync_consumer.py matrix consumers.json)" >> "$GITHUB_OUTPUT"
37+
38+
sync:
39+
name: Sync ${{ matrix.repository }}
40+
needs: consumers
41+
if: ${{ needs.consumers.outputs.matrix != '{"include":[]}' }}
42+
strategy:
43+
fail-fast: false
44+
matrix: ${{ fromJSON(needs.consumers.outputs.matrix) }}
45+
runs-on: ubuntu-latest
46+
timeout-minutes: 10
47+
steps:
48+
- name: Checkout workflow source
49+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
50+
with:
51+
persist-credentials: false
52+
path: source
53+
54+
- name: Checkout consumer
55+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
56+
with:
57+
repository: ${{ matrix.repository }}
58+
token: ${{ secrets.WORKFLOW_UPDATE_TOKEN }}
59+
persist-credentials: false
60+
path: target
61+
62+
- name: Synchronize managed workflows
63+
id: sync
64+
continue-on-error: true
65+
working-directory: source
66+
env:
67+
CONSUMER_REPOSITORY: ${{ matrix.repository }}
68+
run: >-
69+
python3 scripts/sync_consumer.py sync
70+
consumers.json
71+
"$CONSUMER_REPOSITORY"
72+
workflow-templates
73+
../target
74+
--report "../consumer-sync-report.json"
75+
--body "../consumer-sync-pr.md"
76+
77+
- name: Create consumer update pull request
78+
if: ${{ steps.sync.outcome == 'success' }}
79+
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
80+
with:
81+
token: ${{ secrets.WORKFLOW_UPDATE_TOKEN }}
82+
path: target
83+
commit-message: 'ci: sync LibreCode workflow templates'
84+
committer: GitHub <noreply@github.com>
85+
author: github-workflows bot <noreply@github.com>
86+
signoff: true
87+
branch: 'automated/sync-librcode-workflows'
88+
delete-branch: true
89+
title: 'ci: sync LibreCode workflow templates'
90+
body-path: consumer-sync-pr.md
91+
add-paths: |
92+
.github/workflows/**
93+
.github/librecode-workflows.lock
94+
95+
- name: Fail on consumer divergence
96+
if: ${{ steps.sync.outcome == 'failure' }}
97+
run: |
98+
cat consumer-sync-pr.md
99+
exit 1

‎consumers.json‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"consumers": [
3+
{
4+
"repository": "LibreCodeCoop/extract",
5+
"workflows": [
6+
"reuse.yml"
7+
]
8+
}
9+
]
10+
}

‎consumers.json.license‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
2+
SPDX-License-Identifier: AGPL-3.0-or-later

0 commit comments

Comments
 (0)