Skip to content

Commit aafa94d

Browse files
Merge pull request #943 from nextcloud/feat/workflow-auto-update-all-templates-stable31
[stable31] ci: update all workflow templates from organization template repository
2 parents eeaad8a + b1df317 commit aafa94d

21 files changed

+700
-123
lines changed

.github/workflows/block-merge-freeze.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,29 @@ jobs:
2929

3030
steps:
3131
- name: Register server reference to fallback to master branch
32-
run: |
33-
server_ref="$(if [ '${{ github.base_ref }}' = 'main' ]; then echo -n 'master'; else echo -n '${{ github.base_ref }}'; fi)"
34-
echo "server_ref=$server_ref" >> $GITHUB_ENV
32+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
33+
with:
34+
github-token: ${{secrets.GITHUB_TOKEN}}
35+
script: |
36+
const baseRef = context.payload.pull_request.base.ref
37+
if (baseRef === 'main' || baseRef === 'master') {
38+
core.exportVariable('server_ref', 'master');
39+
console.log('Setting server_ref to master');
40+
} else {
41+
const regex = /^stable(\d+)$/
42+
const match = baseRef.match(regex)
43+
if (match) {
44+
core.exportVariable('server_ref', match[0]);
45+
console.log('Setting server_ref to ' + match[0]);
46+
} else {
47+
console.log('Not based on master/main/stable*, so skipping freeze check');
48+
}
49+
}
50+
3551
- name: Download version.php from ${{ env.server_ref }}
52+
if: ${{ env.server_ref != '' }}
3653
run: curl 'https://raw.githubusercontent.com/nextcloud/server/${{ env.server_ref }}/version.php' --output version.php
3754

3855
- name: Run check
56+
if: ${{ env.server_ref != '' }}
3957
run: cat version.php | grep 'OC_VersionString' | grep -i -v 'RC'

.github/workflows/command-compile.yml

Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
issue_comment:
1212
types: [created]
1313

14+
permissions:
15+
contents: read
16+
1417
jobs:
1518
init:
1619
runs-on: ubuntu-latest
@@ -27,7 +30,7 @@ jobs:
2730

2831
steps:
2932
- name: Get repository from pull request comment
30-
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
33+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
3134
id: get-repository
3235
with:
3336
github-token: ${{secrets.GITHUB_TOKEN}}
@@ -54,7 +57,7 @@ jobs:
5457
require: write
5558

5659
- name: Add reaction on start
57-
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
60+
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
5861
with:
5962
token: ${{ secrets.COMMAND_BOT_PAT }}
6063
repository: ${{ github.event.repository.full_name }}
@@ -76,11 +79,11 @@ jobs:
7679
fi
7780
7881
- name: Init branch
79-
uses: xt0rted/pull-request-comment-branch@d97294d304604fa98a2600a6e2f916a84b596dc7 # v1
82+
uses: xt0rted/pull-request-comment-branch@e8b8daa837e8ea7331c0003c9c316a64c6d8b0b1 # v3.0.0
8083
id: comment-branch
8184

8285
- name: Add reaction on failure
83-
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
86+
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
8487
if: failure()
8588
with:
8689
token: ${{ secrets.COMMAND_BOT_PAT }}
@@ -94,14 +97,16 @@ jobs:
9497

9598
steps:
9699
- name: Restore cached git repository
97-
uses: buildjet/cache@e376f15c6ec6dc595375c78633174c7e5f92dc0e # v3
100+
uses: buildjet/cache@3e70d19e31d6a8030aeddf6ed8dbe601f94d09f4 # v4.0.2
98101
with:
99102
path: .git
100103
key: git-repo
101104

102105
- name: Checkout ${{ needs.init.outputs.head_ref }}
103-
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
106+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
104107
with:
108+
# Needed to allow force push later
109+
persist-credentials: true
105110
token: ${{ secrets.COMMAND_BOT_PAT }}
106111
fetch-depth: 0
107112
ref: ${{ needs.init.outputs.head_ref }}
@@ -115,23 +120,57 @@ jobs:
115120
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
116121
id: package-engines-versions
117122
with:
118-
fallbackNode: '^20'
119-
fallbackNpm: '^10'
123+
fallbackNode: '^24'
124+
fallbackNpm: '^11.3'
120125

121126
- name: Set up node ${{ steps.package-engines-versions.outputs.nodeVersion }}
122-
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
127+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
123128
with:
124129
node-version: ${{ steps.package-engines-versions.outputs.nodeVersion }}
125130
cache: npm
126131

127132
- name: Set up npm ${{ steps.package-engines-versions.outputs.npmVersion }}
128133
run: npm i -g 'npm@${{ steps.package-engines-versions.outputs.npmVersion }}'
129-
134+
130135
- name: Rebase to ${{ needs.init.outputs.base_ref }}
131136
if: ${{ contains(needs.init.outputs.arg1, 'rebase') }}
132137
run: |
133138
git fetch origin '${{ needs.init.outputs.base_ref }}:${{ needs.init.outputs.base_ref }}'
134-
git rebase 'origin/${{ needs.init.outputs.base_ref }}'
139+
140+
# Start the rebase
141+
git rebase 'origin/${{ needs.init.outputs.base_ref }}' || {
142+
# Handle rebase conflicts in a loop
143+
while [ -d .git/rebase-merge ] || [ -d .git/rebase-apply ]; do
144+
echo "Handling rebase conflict..."
145+
146+
# Remove and checkout /dist and /js folders from the base branch
147+
if [ -d "dist" ]; then
148+
rm -rf dist
149+
git checkout origin/${{ needs.init.outputs.base_ref }} -- dist/ 2>/dev/null || echo "No dist folder in base branch"
150+
fi
151+
if [ -d "js" ]; then
152+
rm -rf js
153+
git checkout origin/${{ needs.init.outputs.base_ref }} -- js/ 2>/dev/null || echo "No js folder in base branch"
154+
fi
155+
156+
# Stage all changes
157+
git add .
158+
159+
# Check if there are any changes after resolving conflicts
160+
if git diff --cached --quiet; then
161+
echo "No changes after conflict resolution, skipping commit"
162+
git rebase --skip
163+
else
164+
echo "Changes found, continuing rebase without editing commit message"
165+
git -c core.editor=true rebase --continue
166+
fi
167+
168+
# Break if rebase is complete
169+
if [ ! -d .git/rebase-merge ] && [ ! -d .git/rebase-apply ]; then
170+
break
171+
fi
172+
done
173+
}
135174
136175
- name: Install dependencies & build
137176
env:
@@ -146,7 +185,7 @@ jobs:
146185
run: |
147186
git add '${{ github.workspace }}${{ needs.init.outputs.git_path }}'
148187
git commit --signoff -m 'chore(assets): Recompile assets'
149-
188+
150189
- name: Commit fixup
151190
if: ${{ contains(needs.init.outputs.arg1, 'fixup') }}
152191
run: |
@@ -163,14 +202,18 @@ jobs:
163202
164203
- name: Push normally
165204
if: ${{ !contains(needs.init.outputs.arg1, 'rebase') && !contains(needs.init.outputs.arg1, 'amend') }}
166-
run: git push origin '${{ needs.init.outputs.head_ref }}'
205+
env:
206+
HEAD_REF: ${{ needs.init.outputs.head_ref }}
207+
run: git push origin "$HEAD_REF"
167208

168209
- name: Force push
169210
if: ${{ contains(needs.init.outputs.arg1, 'rebase') || contains(needs.init.outputs.arg1, 'amend') }}
170-
run: git push --force origin '${{ needs.init.outputs.head_ref }}'
211+
env:
212+
HEAD_REF: ${{ needs.init.outputs.head_ref }}
213+
run: git push --force-with-lease origin "$HEAD_REF"
171214

172215
- name: Add reaction on failure
173-
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
216+
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
174217
if: failure()
175218
with:
176219
token: ${{ secrets.COMMAND_BOT_PAT }}

.github/workflows/command-openapi.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
issue_comment:
1212
types: [created]
1313

14+
permissions:
15+
contents: read
16+
1417
jobs:
1518
init:
1619
runs-on: ubuntu-latest
@@ -27,7 +30,7 @@ jobs:
2730

2831
steps:
2932
- name: Get repository from pull request comment
30-
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
33+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
3134
id: get-repository
3235
with:
3336
github-token: ${{secrets.GITHUB_TOKEN}}
@@ -54,7 +57,7 @@ jobs:
5457
require: write
5558

5659
- name: Add reaction on start
57-
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
60+
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
5861
with:
5962
token: ${{ secrets.COMMAND_BOT_PAT }}
6063
repository: ${{ github.event.repository.full_name }}
@@ -80,7 +83,7 @@ jobs:
8083
id: comment-branch
8184

8285
- name: Add reaction on failure
83-
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
86+
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
8487
if: failure()
8588
with:
8689
token: ${{ secrets.COMMAND_BOT_PAT }}
@@ -94,15 +97,16 @@ jobs:
9497

9598
steps:
9699
- name: Restore cached git repository
97-
uses: buildjet/cache@e376f15c6ec6dc595375c78633174c7e5f92dc0e # v3
100+
uses: buildjet/cache@3e70d19e31d6a8030aeddf6ed8dbe601f94d09f4 # v4.0.2
98101
with:
99102
path: .git
100103
key: git-repo
101104

102105
- name: Checkout ${{ needs.init.outputs.head_ref }}
103-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
106+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
104107
with:
105-
persist-credentials: false
108+
# Needed to allow force push later
109+
persist-credentials: true
106110
token: ${{ secrets.COMMAND_BOT_PAT }}
107111
fetch-depth: 0
108112
ref: ${{ needs.init.outputs.head_ref }}
@@ -125,12 +129,12 @@ jobs:
125129
# Continue if no package.json
126130
continue-on-error: true
127131
with:
128-
fallbackNode: '^20'
129-
fallbackNpm: '^10'
132+
fallbackNode: '^24'
133+
fallbackNpm: '^11.3'
130134

131135
- name: Set up node ${{ steps.node_versions.outputs.nodeVersion }}
132136
if: ${{ steps.node_versions.outputs.nodeVersion }}
133-
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
137+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
134138
with:
135139
node-version: ${{ steps.node_versions.outputs.nodeVersion }}
136140

@@ -183,10 +187,10 @@ jobs:
183187

184188
- name: Force push
185189
if: ${{ contains(needs.init.outputs.arg1, 'rebase') || contains(needs.init.outputs.arg1, 'amend') }}
186-
run: git push --force origin '${{ needs.init.outputs.head_ref }}'
190+
run: git push --force-with-lease origin '${{ needs.init.outputs.head_ref }}'
187191

188192
- name: Add reaction on failure
189-
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
193+
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
190194
if: failure()
191195
with:
192196
token: ${{ secrets.COMMAND_BOT_PAT }}

.github/workflows/dependabot-approve-merge.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
# https://github.com/nextcloud/.github
44
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
55
#
6-
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
6+
# SPDX-FileCopyrightText: Nextcloud GmbH and Nextcloud contributors
77
# SPDX-License-Identifier: MIT
88

9-
name: Dependabot
9+
name: Auto approve Dependabot PRs
1010

1111
on:
12-
pull_request_target:
12+
pull_request_target: # zizmor: ignore[dangerous-triggers]
1313
branches:
1414
- main
1515
- master
@@ -24,11 +24,13 @@ concurrency:
2424

2525
jobs:
2626
auto-approve-merge:
27-
if: github.actor == 'dependabot[bot]' || github.actor == 'renovate[bot]'
27+
if: github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.user.login == 'renovate[bot]'
2828
runs-on: ubuntu-latest-low
2929
permissions:
3030
# for hmarr/auto-approve-action to approve PRs
3131
pull-requests: write
32+
# for alexwilson/enable-github-automerge-action to approve PRs
33+
contents: write
3234

3335
steps:
3436
- name: Disabled on forks
@@ -37,13 +39,20 @@ jobs:
3739
echo 'Can not approve PRs from forks'
3840
exit 1
3941
42+
- uses: mdecoleman/pr-branch-name@55795d86b4566d300d237883103f052125cc7508 # v3.0.0
43+
id: branchname
44+
with:
45+
repo-token: ${{ secrets.GITHUB_TOKEN }}
46+
4047
# GitHub actions bot approve
41-
- uses: hmarr/auto-approve-action@b40d6c9ed2fa10c9a2749eca7eb004418a705501 # v2
48+
- uses: hmarr/auto-approve-action@f0939ea97e9205ef24d872e76833fa908a770363 # v4.0.0
49+
if: startsWith(steps.branchname.outputs.branch, 'dependabot/')
4250
with:
4351
github-token: ${{ secrets.GITHUB_TOKEN }}
4452

45-
# Nextcloud bot approve and merge request
46-
- uses: ahmadnassri/action-dependabot-auto-merge@45fc124d949b19b6b8bf6645b6c9d55f4f9ac61a # v2
53+
# Enable GitHub auto merge
54+
- name: Auto merge
55+
uses: alexwilson/enable-github-automerge-action@56e3117d1ae1540309dc8f7a9f2825bc3c5f06ff # v2.0.0
56+
if: startsWith(steps.branchname.outputs.branch, 'dependabot/')
4757
with:
48-
target: minor
49-
github-token: ${{ secrets.DEPENDABOT_AUTOMERGE_TOKEN }}
58+
github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/lint-eslint.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,19 @@ jobs:
5656

5757
steps:
5858
- name: Checkout
59-
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
59+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
60+
with:
61+
persist-credentials: false
6062

6163
- name: Read package.json node and npm engines version
6264
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
6365
id: versions
6466
with:
65-
fallbackNode: '^20'
66-
fallbackNpm: '^10'
67+
fallbackNode: '^24'
68+
fallbackNpm: '^11.3'
6769

6870
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
69-
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
71+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
7072
with:
7173
node-version: ${{ steps.versions.outputs.nodeVersion }}
7274

.github/workflows/lint-php-cs.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,28 @@ jobs:
2525

2626
steps:
2727
- name: Checkout
28-
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
28+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
29+
with:
30+
persist-credentials: false
2931

3032
- name: Get php version
3133
id: versions
3234
uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1
3335

34-
- name: Set up php${{ steps.versions.outputs.php-available }}
35-
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
36+
- name: Set up php${{ steps.versions.outputs.php-min }}
37+
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # v2.35.5
3638
with:
37-
php-version: ${{ steps.versions.outputs.php-available }}
39+
php-version: ${{ steps.versions.outputs.php-min }}
3840
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
3941
coverage: none
4042
ini-file: development
4143
env:
4244
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4345

4446
- name: Install dependencies
45-
run: composer i
47+
run: |
48+
composer remove nextcloud/ocp --dev --no-scripts
49+
composer i
4650
4751
- name: Lint
4852
run: composer run cs:check || ( echo 'Please run `composer run cs:fix` to format your code' && exit 1 )

0 commit comments

Comments
 (0)