Skip to content

Commit 40ed4aa

Browse files
Merge pull request #705 from nextcloud/ci/noid/actions
ci(actions): Update workflow templates
2 parents 058fe4c + 2ee3740 commit 40ed4aa

18 files changed

Lines changed: 5973 additions & 2754 deletions

.github/workflows/command-compile.yml

Lines changed: 83 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
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: 2021-2024 Nextcloud GmbH and Nextcloud contributors
7+
# SPDX-License-Identifier: MIT
8+
19
name: Compile Command
210
on:
311
issue_comment:
412
types: [created]
513

14+
permissions:
15+
contents: read
16+
617
jobs:
718
init:
8-
runs-on: ubuntu-latest
19+
runs-on: ubuntu-latest-low
920

1021
# On pull requests and if the comment starts with `/compile`
1122
if: github.event.issue.pull_request != '' && startsWith(github.event.comment.body, '/compile')
@@ -19,7 +30,7 @@ jobs:
1930

2031
steps:
2132
- name: Get repository from pull request comment
22-
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
33+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
2334
id: get-repository
2435
with:
2536
github-token: ${{secrets.GITHUB_TOKEN}}
@@ -46,12 +57,12 @@ jobs:
4657
require: write
4758

4859
- name: Add reaction on start
49-
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
60+
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
5061
with:
5162
token: ${{ secrets.COMMAND_BOT_PAT }}
5263
repository: ${{ github.event.repository.full_name }}
5364
comment-id: ${{ github.event.comment.id }}
54-
reactions: "+1"
65+
reactions: '+1'
5566

5667
- name: Parse command
5768
uses: skjnldsv/parse-command-comment@5c955203c52424151e6d0e58fb9de8a9f6a605a1 # v2
@@ -68,53 +79,98 @@ jobs:
6879
fi
6980
7081
- name: Init branch
71-
uses: xt0rted/pull-request-comment-branch@d97294d304604fa98a2600a6e2f916a84b596dc7 # v1
82+
uses: xt0rted/pull-request-comment-branch@e8b8daa837e8ea7331c0003c9c316a64c6d8b0b1 # v3.0.0
7283
id: comment-branch
7384

85+
- name: Add reaction on failure
86+
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
87+
if: failure()
88+
with:
89+
token: ${{ secrets.COMMAND_BOT_PAT }}
90+
repository: ${{ github.event.repository.full_name }}
91+
comment-id: ${{ github.event.comment.id }}
92+
reactions: '-1'
93+
7494
process:
7595
runs-on: ubuntu-latest
7696
needs: init
7797

7898
steps:
7999
- name: Restore cached git repository
80-
uses: buildjet/cache@e376f15c6ec6dc595375c78633174c7e5f92dc0e # v3
100+
uses: buildjet/cache@3e70d19e31d6a8030aeddf6ed8dbe601f94d09f4 # v4.0.2
81101
with:
82102
path: .git
83103
key: git-repo
84104

85105
- name: Checkout ${{ needs.init.outputs.head_ref }}
86-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
106+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
87107
with:
108+
# Needed to allow force push later
109+
persist-credentials: true
88110
token: ${{ secrets.COMMAND_BOT_PAT }}
89111
fetch-depth: 0
90112
ref: ${{ needs.init.outputs.head_ref }}
91113

92114
- name: Setup git
93115
run: |
94-
git config --local user.email "nextcloud-command@users.noreply.github.com"
95-
git config --local user.name "nextcloud-command"
116+
git config --local user.email 'nextcloud-command@users.noreply.github.com'
117+
git config --local user.name 'nextcloud-command'
96118
97119
- name: Read package.json node and npm engines version
98-
uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2
120+
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
99121
id: package-engines-versions
100122
with:
101-
fallbackNode: '^20'
102-
fallbackNpm: '^10'
123+
fallbackNode: '^24'
124+
fallbackNpm: '^11.3'
103125

104126
- name: Set up node ${{ steps.package-engines-versions.outputs.nodeVersion }}
105-
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v3
127+
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
106128
with:
107129
node-version: ${{ steps.package-engines-versions.outputs.nodeVersion }}
108130
cache: npm
109131

110132
- name: Set up npm ${{ steps.package-engines-versions.outputs.npmVersion }}
111-
run: npm i -g npm@"${{ steps.package-engines-versions.outputs.npmVersion }}"
133+
run: npm i -g 'npm@${{ steps.package-engines-versions.outputs.npmVersion }}'
112134

113135
- name: Rebase to ${{ needs.init.outputs.base_ref }}
114136
if: ${{ contains(needs.init.outputs.arg1, 'rebase') }}
115137
run: |
116-
git fetch origin ${{ needs.init.outputs.base_ref }}:${{ needs.init.outputs.base_ref }}
117-
git rebase origin/${{ needs.init.outputs.base_ref }}
138+
git fetch origin '${{ needs.init.outputs.base_ref }}:${{ 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+
}
118174
119175
- name: Install dependencies & build
120176
env:
@@ -127,36 +183,40 @@ jobs:
127183
- name: Commit default
128184
if: ${{ !contains(needs.init.outputs.arg1, 'fixup') && !contains(needs.init.outputs.arg1, 'amend') }}
129185
run: |
130-
git add ${{ github.workspace }}${{ needs.init.outputs.git_path }}
186+
git add '${{ github.workspace }}${{ needs.init.outputs.git_path }}'
131187
git commit --signoff -m 'chore(assets): Recompile assets'
132188
133189
- name: Commit fixup
134190
if: ${{ contains(needs.init.outputs.arg1, 'fixup') }}
135191
run: |
136-
git add ${{ github.workspace }}${{ needs.init.outputs.git_path }}
192+
git add '${{ github.workspace }}${{ needs.init.outputs.git_path }}'
137193
git commit --fixup=HEAD --signoff
138194
139195
- name: Commit amend
140196
if: ${{ contains(needs.init.outputs.arg1, 'amend') }}
141197
run: |
142-
git add ${{ github.workspace }}${{ needs.init.outputs.git_path }}
198+
git add '${{ github.workspace }}${{ needs.init.outputs.git_path }}'
143199
git commit --amend --no-edit --signoff
144200
# Remove any [skip ci] from the amended commit
145201
git commit --amend -m "$(git log -1 --format='%B' | sed '/\[skip ci\]/d')"
146202
147203
- name: Push normally
148204
if: ${{ !contains(needs.init.outputs.arg1, 'rebase') && !contains(needs.init.outputs.arg1, 'amend') }}
149-
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"
150208

151209
- name: Force push
152210
if: ${{ contains(needs.init.outputs.arg1, 'rebase') || contains(needs.init.outputs.arg1, 'amend') }}
153-
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"
154214

155215
- name: Add reaction on failure
156-
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
216+
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
157217
if: failure()
158218
with:
159219
token: ${{ secrets.COMMAND_BOT_PAT }}
160220
repository: ${{ github.event.repository.full_name }}
161221
comment-id: ${{ github.event.comment.id }}
162-
reactions: "-1"
222+
reactions: '-1'

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

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
#
33
# https://github.com/nextcloud/.github
44
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5+
#
6+
# SPDX-FileCopyrightText: Nextcloud GmbH and Nextcloud contributors
7+
# SPDX-License-Identifier: MIT
58

6-
name: Dependabot
9+
name: Auto approve Dependabot PRs
710

811
on:
9-
pull_request_target:
12+
pull_request_target: # zizmor: ignore[dangerous-triggers]
1013
branches:
1114
- main
1215
- master
@@ -21,11 +24,13 @@ concurrency:
2124

2225
jobs:
2326
auto-approve-merge:
24-
if: github.actor == 'dependabot[bot]'
25-
runs-on: ubuntu-latest
27+
if: github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.user.login == 'renovate[bot]'
28+
runs-on: ubuntu-latest-low
2629
permissions:
2730
# for hmarr/auto-approve-action to approve PRs
2831
pull-requests: write
32+
# for alexwilson/enable-github-automerge-action to approve PRs
33+
contents: write
2934

3035
steps:
3136
- name: Disabled on forks
@@ -34,13 +39,20 @@ jobs:
3439
echo 'Can not approve PRs from forks'
3540
exit 1
3641
37-
# Github actions bot approve
38-
- uses: hmarr/auto-approve-action@b40d6c9ed2fa10c9a2749eca7eb004418a705501 # v2
42+
- uses: mdecoleman/pr-branch-name@55795d86b4566d300d237883103f052125cc7508 # v3.0.0
43+
id: branchname
44+
with:
45+
repo-token: ${{ secrets.GITHUB_TOKEN }}
46+
47+
# GitHub actions bot approve
48+
- uses: hmarr/auto-approve-action@f0939ea97e9205ef24d872e76833fa908a770363 # v4.0.0
49+
if: startsWith(steps.branchname.outputs.branch, 'dependabot/')
3950
with:
4051
github-token: ${{ secrets.GITHUB_TOKEN }}
4152

42-
# Nextcloud bot approve and merge request
43-
- 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/')
4457
with:
45-
target: minor
46-
github-token: ${{ secrets.DEPENDABOT_AUTOMERGE_TOKEN }}
58+
github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/fixup.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
#
33
# https://github.com/nextcloud/.github
44
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5+
#
6+
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
7+
# SPDX-License-Identifier: MIT
58

6-
name: Pull request checks
9+
name: Block fixup and squash commits
710

811
on:
912
pull_request:
@@ -24,10 +27,10 @@ jobs:
2427
pull-requests: write
2528
name: Block fixup and squash commits
2629

27-
runs-on: ubuntu-latest
30+
runs-on: ubuntu-latest-low
2831

2932
steps:
3033
- name: Run check
31-
uses: xt0rted/block-autosquash-commits-action@79880c36b4811fe549cfffe20233df88876024e7 # v2
34+
uses: skjnldsv/block-fixup-merge-action@c138ea99e45e186567b64cf065ce90f7158c236a # v2
3235
with:
3336
repo-token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)