Skip to content

Commit 119ba4d

Browse files
Merge pull request #934 from nextcloud/backport/906/stable32
[stable32] ci: Migrate to composer-bin and add sync workflow
2 parents d367902 + 9e583bc commit 119ba4d

25 files changed

Lines changed: 6618 additions & 5153 deletions

.github/dependabot.yml

Lines changed: 64 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,66 @@
11
version: 2
22
updates:
3-
- package-ecosystem: composer
4-
directory: "/"
5-
schedule:
6-
interval: weekly
7-
day: saturday
8-
time: "03:00"
9-
timezone: Europe/Paris
10-
open-pull-requests-limit: 10
11-
labels:
12-
- 3. to review
13-
- dependencies
14-
- package-ecosystem: composer
15-
directory: "/tests/Integration"
16-
schedule:
17-
interval: weekly
18-
day: saturday
19-
time: "03:00"
20-
timezone: Europe/Paris
21-
open-pull-requests-limit: 10
22-
labels:
23-
- 3. to review
24-
- dependencies
3+
- package-ecosystem: composer
4+
directories:
5+
- "/"
6+
- "/tests/Integration"
7+
- "/vendor-bin/csfixer"
8+
- "/vendor-bin/openapi-extractor"
9+
- "/vendor-bin/phpunit"
10+
- "/vendor-bin/psalm"
11+
- "/vendor-bin/rector"
12+
schedule:
13+
interval: weekly
14+
day: saturday
15+
time: "03:00"
16+
timezone: Europe/Paris
17+
commit-message:
18+
prefix: "build"
19+
include: "scope"
20+
versioning-strategy: "increase"
21+
labels:
22+
- 3. to review
23+
- dependencies
24+
cooldown:
25+
default-days: 7
26+
27+
- package-ecosystem: "github-actions"
28+
directory: ".github/workflows"
29+
commit-message:
30+
prefix: "ci"
31+
include: "scope"
32+
schedule:
33+
interval: weekly
34+
day: saturday
35+
time: "03:00"
36+
timezone: Europe/Berlin
37+
cooldown:
38+
default-days: 7
39+
40+
- package-ecosystem: "github-actions"
41+
target-branch: stable33
42+
directory: ".github/workflows"
43+
commit-message:
44+
prefix: "ci"
45+
include: "scope"
46+
schedule:
47+
interval: weekly
48+
day: saturday
49+
time: "03:00"
50+
timezone: Europe/Berlin
51+
cooldown:
52+
default-days: 7
53+
54+
- package-ecosystem: "github-actions"
55+
target-branch: stable32
56+
directory: ".github/workflows"
57+
commit-message:
58+
prefix: "ci"
59+
include: "scope"
60+
schedule:
61+
interval: weekly
62+
day: saturday
63+
time: "03:00"
64+
timezone: Europe/Berlin
65+
cooldown:
66+
default-days: 7
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# This workflow is provided via the organization template repository
2+
#
3+
# https://github.com/nextcloud/.github
4+
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5+
#
6+
# SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
7+
# SPDX-License-Identifier: MIT
8+
9+
# This workflow will update all workflow templates
10+
# Additionally it will reapply `workflow.yml.patch` files after syncing and only then commit the result
11+
name: Update workflows
12+
on:
13+
workflow_dispatch:
14+
schedule:
15+
- cron: "5 2 * * 0"
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
dispatch:
22+
runs-on: ubuntu-latest
23+
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
branches:
28+
- ${{ github.event.repository.default_branch }}
29+
- 'stable33'
30+
- 'stable32'
31+
32+
name: Update workflows in ${{ matrix.branches }}
33+
34+
permissions:
35+
contents: write
36+
pull-requests: write
37+
38+
steps:
39+
- name: Check actor permission
40+
uses: skjnldsv/check-actor-permission@69e92a3c4711150929bca9fcf34448c5bf5526e7 # v3.0
41+
with:
42+
require: admin
43+
44+
- name: Checkout workflow repository
45+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
46+
with:
47+
persist-credentials: false
48+
path: source
49+
repository: nextcloud/.github
50+
51+
- name: Checkout app
52+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
53+
with:
54+
persist-credentials: false
55+
path: target
56+
ref: ${{ matrix.branches }}
57+
58+
- name: Copy all workflow templates
59+
run: |
60+
echo 'SUMMARY<<EOF' >> $GITHUB_ENV
61+
draft_only=0
62+
for workflow in ./source/workflow-templates/*.yml; do
63+
echo "❓ Looking for $workflow"
64+
if [ -f "$workflow" ]; then
65+
filename=$(basename "$workflow")
66+
target_file="./target/.github/workflows/$filename"
67+
68+
# Only copy if the file exists in the target repository
69+
if [ -f "$target_file" ]; then
70+
if [ -f "./target/.github/actions-lock.txt" ]; then
71+
locked_version=$(grep " $filename" ./target/.github/actions-lock.txt | cat)
72+
else
73+
echo "# SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors" >> ./target/.github/actions-lock.txt
74+
echo "# SPDX-License""-Identifier: MIT" >> ./target/.github/actions-lock.txt
75+
locked_version=""
76+
fi
77+
locked_version=$(echo $locked_version | cut -f 1 -d " ")
78+
new_version=$(md5sum $workflow | cut -f 1 -d " ")
79+
80+
# Only update if the action changes
81+
if [[ "$locked_version" != "$new_version" ]]; then
82+
echo "ℹ️ Locked version: $locked_version"
83+
echo "ℹ️ Current version: $new_version"
84+
echo "🆙 Updating existing workflow: $filename"
85+
echo "- 🆙 Updated [$filename](https://github.com/nextcloud/.github/commits/master/workflow-templates/$filename)" >> $GITHUB_ENV
86+
87+
cp "$workflow" "$target_file"
88+
89+
# Apply patch if one exists
90+
if [ -f "$target_file.patch" ]; then
91+
echo "🩹 Applying patch"
92+
cd ./target
93+
set +e
94+
patch -p1 < ".github/workflows/$filename.patch"
95+
patch_worked=$?
96+
set -e
97+
cd -
98+
if [[ "$patch_worked" == "0" ]]; then
99+
echo " - Patch applied" >> $GITHUB_ENV
100+
else
101+
echo " - [ ] ❌ Patch failed" >> $GITHUB_ENV
102+
draft_only=1
103+
fi
104+
fi
105+
106+
if [[ "$locked_version" != "" ]]; then
107+
sed -i "s/$locked_version $filename/$new_version $filename/" ./target/.github/actions-lock.txt
108+
else
109+
echo "$new_version $filename" >> ./target/.github/actions-lock.txt
110+
fi
111+
else
112+
echo "✅ Skipping $filename: already up to date"
113+
fi
114+
else
115+
echo "⏭️ Skipping $filename: does not exist in target repository"
116+
fi
117+
fi
118+
done
119+
echo 'EOF' >> $GITHUB_ENV
120+
echo "DRAFT_ONLY=${draft_only}" >> $GITHUB_ENV
121+
122+
- name: Create Pull Request
123+
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
124+
with:
125+
token: ${{ secrets.COMMAND_BOT_WORKFLOWS }} # zizmor: ignore[secrets-outside-env]
126+
commit-message: 'ci(actions): Update workflow templates from organization template repository'
127+
committer: GitHub <noreply@github.com>
128+
author: nextcloud-command <nextcloud-command@users.noreply.github.com>
129+
path: target
130+
signoff: true
131+
branch: 'automated/noid/${{ matrix.branches }}-update-workflows'
132+
title: '[${{ matrix.branches }}] ci(actions): Update workflow templates from organization template repository'
133+
draft: ${{ env.DRAFT_ONLY == 1 }}
134+
add-paths: .github/workflows/*.yml,.github/actions-lock.txt
135+
body: |
136+
Automated update of all workflow templates from [nextcloud/.github](https://github.com/nextcloud/.github)
137+
${{ env.SUMMARY }}
138+
labels: |
139+
dependencies
140+
3. to review

.github/workflows/update-nextcloud-ocp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
- name: Composer update nextcloud/ocp # zizmor: ignore[template-injection]
6666
id: update_branch
6767
if: ${{ steps.checkout.outcome == 'success' && matrix.branches != 'main' }}
68-
run: composer require --dev 'nextcloud/ocp:dev-${{ matrix.branches }}'
68+
run: composer bin nextcloud-ocp require --dev 'nextcloud/ocp:dev-${{ matrix.branches }}'
6969

7070
- name: Raise on issue on failure
7171
uses: dacbd/create-issue-action@cdb57ab6ff8862aa09fee2be6ba77a59581921c2 # v2.0.0
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/.github/workflows/update-nextcloud-ocp.yml b/.github/workflows/update-nextcloud-ocp.yml
2+
index 873bf119..760faece 100644
3+
--- a/.github/workflows/update-nextcloud-ocp.yml
4+
+++ b/.github/workflows/update-nextcloud-ocp.yml
5+
@@ -65,7 +65,7 @@ jobs:
6+
- name: Composer update nextcloud/ocp # zizmor: ignore[template-injection]
7+
id: update_branch
8+
if: ${{ steps.checkout.outcome == 'success' && matrix.branches != 'main' }}
9+
- run: composer require --dev 'nextcloud/ocp:dev-${{ matrix.branches }}'
10+
+ run: composer bin nextcloud-ocp require --dev 'nextcloud/ocp:dev-${{ matrix.branches }}'
11+
12+
- name: Raise on issue on failure
13+
uses: dacbd/create-issue-action@cdb57ab6ff8862aa09fee2be6ba77a59581921c2 # v2.0.0

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ build/
6262

6363
# Composer
6464
/vendor/
65+
/vendor-bin/*/vendor/
6566
/tests/Integration/output/
6667
/tests/Integration/vendor/
6768

.php-cs-fixer.dist.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* SPDX-License-Identifier: AGPL-3.0-or-later
77
*/
88

9-
require_once './vendor/autoload.php';
9+
require_once './vendor-bin/csfixer/vendor/autoload.php';
1010

1111
use Nextcloud\CodingStandard\Config;
1212

REUSE.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ SPDX-PackageSupplier = "Nextcloud <info@nextcloud.com>"
66
SPDX-PackageDownloadLocation = "https://github.com/nextcloud/files_accesscontrol"
77

88
[[annotations]]
9-
path = [".gitattributes", ".github/CODEOWNERS", ".github/dependabot.yml", ".github/workflows/*.patch", ".editorconfig", "composer.json", "composer.lock", "psalm.xml", "tests/psalm-baseline.xml", "tests/Integration/composer.json", "tests/phpunit.xml", "tests/Integration/composer.lock", ".gitignore", "tests/Integration/data/*", ".tx/config"]
9+
path = [".gitattributes", ".github/CODEOWNERS", ".github/dependabot.yml", ".editorconfig", "composer.json", "composer.lock", "**/composer.json", "**/composer.lock", "psalm.xml", "tests/psalm-baseline.xml", "tests/Integration/composer.json", "tests/phpunit.xml", "tests/Integration/composer.lock", ".gitignore", "tests/Integration/data/*", ".tx/config"]
1010
precedence = "aggregate"
1111
SPDX-FileCopyrightText = "none"
1212
SPDX-License-Identifier = "CC0-1.0"
@@ -18,7 +18,7 @@ SPDX-FileCopyrightText = "2023 Nextcloud GmbH and Nextcloud contributors"
1818
SPDX-License-Identifier = "CC0-1.0"
1919

2020
[[annotations]]
21-
path = [".github/issue_template.md", ".github/contributing.md"]
21+
path = [".github/issue_template.md", ".github/contributing.md", ".github/workflows/*.patch"]
2222
precedence = "aggregate"
2323
SPDX-FileCopyrightText = "2016 Nextcloud GmbH and Nextcloud contributors"
2424
SPDX-License-Identifier = "CC0-1.0"

composer.json

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,34 @@
88
"optimize-autoloader": true,
99
"classmap-authoritative": true,
1010
"platform": {
11-
"php": "8.1.32"
11+
"php": "8.1"
1212
},
13-
"sort-packages": true
13+
"sort-packages": true,
14+
"allow-plugins": {
15+
"bamarni/composer-bin-plugin": true
16+
}
1417
},
1518
"scripts": {
19+
"post-install-cmd": [
20+
"@composer bin all install --ansi",
21+
"composer dump-autoload"
22+
],
23+
"post-update-cmd": [
24+
"@composer bin all install --ansi",
25+
"composer dump-autoload"
26+
],
1627
"cs:check": "php-cs-fixer fix --dry-run --diff",
1728
"cs:fix": "php-cs-fixer fix",
18-
"lint": "find . -name \\*.php -not -path './vendor/*' -not -path './build/*' -not -path './tests/integration/vendor/*' -print0 | xargs -0 -n1 php -l",
29+
"lint": "find . -name \\*.php -not -path './vendor/*' -not -path './vendor-bin/*' -not -path './build/*' -not -path './tests/integration/vendor/*' -print0 | xargs -0 -n1 php -l",
1930
"psalm": "psalm --no-cache --threads=$(nproc)",
2031
"psalm:dev": "@psalm",
2132
"psalm:update-baseline": "psalm --threads=1 --update-baseline",
22-
"test:unit": "vendor/bin/phpunit --color -c tests/phpunit.xml",
33+
"rector:check": "rector --dry-run --clear-cache",
34+
"rector:fix": "rector",
35+
"test:unit": "phpunit --color -c tests/phpunit.xml",
2336
"test:integration": "cd tests/Integration && ./run.sh"
2437
},
25-
"require-dev": {
26-
"friendsofphp/php-cs-fixer": "^3.82.0",
27-
"nextcloud/coding-standard": "^1.2.1",
28-
"nextcloud/ocp": "dev-stable32",
29-
"phpunit/phpunit": "^10.5.28",
30-
"vimeo/psalm": "^6.12"
38+
"require": {
39+
"bamarni/composer-bin-plugin": "^1.9.1"
3140
}
3241
}

0 commit comments

Comments
 (0)