Skip to content

Commit db42cec

Browse files
authored
Merge pull request #769 from nextcloud/ci/noid/actions
ci(actions): Update actions and satisfy zizmor
2 parents 807bda3 + 3bfc1b0 commit db42cec

15 files changed

Lines changed: 2488 additions & 77 deletions

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

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,23 @@ jobs:
2727

2828
steps:
2929
- name: Set server major version environment
30-
run: |
31-
# retrieve version number from branch reference
32-
server_major=$(echo "${{ github.base_ref }}" | sed -En 's/stable//p')
33-
echo "server_major=$server_major" >> $GITHUB_ENV
34-
echo "current_month=$(date +%Y-%m)" >> $GITHUB_ENV
35-
36-
- name: Checking if ${{ env.server_major }} is EOL
30+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
31+
with:
32+
github-token: ${{secrets.GITHUB_TOKEN}}
33+
script: |
34+
const regex = /^stable(\d+)$/
35+
const baseRef = context.payload.pull_request.base.ref
36+
const match = baseRef.match(regex)
37+
if (match) {
38+
console.log('Setting server_major to ' + match[1]);
39+
core.exportVariable('server_major', match[1]);
40+
console.log('Setting current_day to ' + (new Date()).toISOString().substr(0, 10));
41+
core.exportVariable('current_day', (new Date()).toISOString().substr(0, 10));
42+
}
43+
44+
- name: Checking if server ${{ env.server_major }} is EOL
45+
if: ${{ env.server_major != '' }}
3746
run: |
3847
curl -s https://raw.githubusercontent.com/nextcloud-releases/updater_server/production/config/major_versions.json \
39-
| jq '.["${{ env.server_major }}"]["eol"] // "9999-99" | . >= "${{ env.current_month }}"' \
48+
| jq '.["${{ env.server_major }}"]["eol"] // "9999-99-99" | . >= "${{ env.current_day }}"' \
4049
| grep -q true
41-

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

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +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'
40-

.github/workflows/command-compile.yml

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

14+
permissions:
15+
contents: read
16+
1417
jobs:
1518
init:
16-
runs-on: ubuntu-latest
19+
runs-on: ubuntu-latest-low
1720

1821
# On pull requests and if the comment starts with `/compile`
1922
if: github.event.issue.pull_request != '' && startsWith(github.event.comment.body, '/compile')
@@ -76,7 +79,7 @@ jobs:
7679
fi
7780
7881
- name: Init branch
79-
uses: xt0rted/pull-request-comment-branch@e8b8daa837e8ea7331c0003c9c316a64c6d8b0b1 # v1
82+
uses: xt0rted/pull-request-comment-branch@e8b8daa837e8ea7331c0003c9c316a64c6d8b0b1 # v3.0.0
8083
id: comment-branch
8184

8285
- name: Add reaction on failure
@@ -94,14 +97,16 @@ jobs:
9497

9598
steps:
9699
- name: Restore cached git repository
97-
uses: buildjet/cache/save@3e70d19e31d6a8030aeddf6ed8dbe601f94d09f4 # v4.0.2
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@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
106+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
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,11 +120,11 @@ 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@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
127+
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
123128
with:
124129
node-version: ${{ steps.package-engines-versions.outputs.nodeVersion }}
125130
cache: npm
@@ -131,7 +136,41 @@ jobs:
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:
@@ -163,11 +202,15 @@ 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
173216
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
@@ -177,4 +220,3 @@ jobs:
177220
repository: ${{ github.event.repository.full_name }}
178221
comment-id: ${{ github.event.comment.id }}
179222
reactions: '-1'
180-

.github/workflows/lint.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ jobs:
2222

2323
steps:
2424
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
25+
with:
26+
persist-credentials: false
2527

2628
- name: Download xml appinfo schema
2729
run: wget https://raw.githubusercontent.com/nextcloud/appstore/master/nextcloudappstore/api/v1/release/info.xsd
@@ -41,6 +43,8 @@ jobs:
4143

4244
steps:
4345
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
46+
with:
47+
persist-credentials: false
4448

4549
- name: Set up php ${{ matrix.php-versions }}
4650
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # v2
@@ -60,6 +64,8 @@ jobs:
6064

6165
steps:
6266
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
67+
with:
68+
persist-credentials: false
6369

6470
- name: Set up php ${{ matrix.php-versions }}
6571
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # v2
@@ -82,6 +88,9 @@ jobs:
8288

8389
steps:
8490
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
91+
with:
92+
persist-credentials: false
93+
8594
- name: Set up php ${{ matrix.php-versions }}
8695
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # v2
8796
with:
@@ -100,6 +109,9 @@ jobs:
100109

101110
steps:
102111
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
112+
with:
113+
persist-credentials: false
114+
103115
- name: Install dependencies
104116
run: npm ci
105117

@@ -113,6 +125,9 @@ jobs:
113125

114126
steps:
115127
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
128+
with:
129+
persist-credentials: false
130+
116131
- name: Install dependencies
117132
run: npm ci
118133

.github/workflows/node-build.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ on:
1818
- stylelint.config.js
1919
- webpack.js
2020

21+
permissions:
22+
contents: read
23+
2124
jobs:
2225
build:
2326
name: node-build
@@ -30,6 +33,7 @@ jobs:
3033
- name: Checkout
3134
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
3235
with:
36+
persist-credentials: false
3337
path: ${{ env.APP_NAME }}
3438

3539
- name: Read package.json node and npm engines version
@@ -43,6 +47,7 @@ jobs:
4347
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
4448
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v3
4549
with:
50+
persist-credentials: false
4651
node-version: ${{ steps.versions.outputs.nodeVersion }}
4752

4853
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}

.github/workflows/node.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,31 @@ jobs:
5353
name: NPM build
5454
steps:
5555
- name: Checkout
56-
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
56+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5757
with:
5858
persist-credentials: false
5959

6060
- name: Read package.json node and npm engines version
6161
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
6262
id: versions
6363
with:
64-
fallbackNode: '^20'
65-
fallbackNpm: '^10'
64+
fallbackNode: '^24'
65+
fallbackNpm: '^11.3'
6666

6767
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
68-
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
68+
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
6969
with:
7070
node-version: ${{ steps.versions.outputs.nodeVersion }}
7171

7272
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
7373
run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}'
7474

75+
- name: Validate package-lock.json # See https://github.com/npm/cli/issues/4460
76+
run: |
77+
npm i -g npm-package-lock-add-resolved@1.1.4
78+
npm-package-lock-add-resolved
79+
git --no-pager diff --exit-code
80+
7581
- name: Install dependencies & build
7682
env:
7783
CYPRESS_INSTALL_BINARY: 0
@@ -80,7 +86,7 @@ jobs:
8086
npm ci
8187
npm run build --if-present
8288
83-
- name: Check webpack build changes
89+
- name: Check build changes
8490
run: |
8591
bash -c "[[ ! \"`git status --porcelain `\" ]] || (echo 'Please recompile and commit the assets, see the section \"Show changes on failure\" for details' && exit 1)"
8692

.github/workflows/pr-feedback.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
blocklist=$(curl https://raw.githubusercontent.com/nextcloud/.github/master/non-community-usernames.txt | paste -s -d, -)
3737
echo "blocklist=$blocklist" >> "$GITHUB_OUTPUT"
3838
39-
- uses: nextcloud/pr-feedback-action@e397f3c7e655092b746e3610d121545530c6a90e # main
39+
- uses: nextcloud/pr-feedback-action@f0cab224dea8e1f282f9451de322f323c78fc7a5 # main
4040
with:
4141
feedback-message: |
4242
Hello there,

.github/workflows/reuse.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ name: REUSE Compliance Check
1111

1212
on: [pull_request]
1313

14+
permissions:
15+
contents: read
16+
1417
jobs:
1518
reuse-compliance-check:
16-
runs-on: ubuntu-latest
19+
runs-on: ubuntu-latest-low
1720
steps:
1821
- name: Checkout
19-
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
22+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2023
with:
2124
persist-credentials: false
2225

0 commit comments

Comments
 (0)